PHP+DOM´´½¨XMLÎļþ
´´½¨ÎĵµÀàÐÍÉùÃ÷
Ò»°ã¶øÑÔ£¬XMLÉùÃ÷·ÅÔÚÎĵµ¶¥²¿¡£ÔÚPHPÖÐÉùÃ÷Ê®·Ö¼òµ¥£ºÖ»ÐèʵÀý»¯Ò»¸öDOMÎĵµÀàµÄ¶ÔÏ󲢸³ÓèËüÒ»¸ö°æ±¾ºÅ¡£²é¿´³ÌÐòÇåµ¥A£º
³ÌÐòÇåµ¥ A
<?php
// create doctype
$dom = new DOMDocument("1.0");
// display document in browser as plain text
// display document in browser as plain text
// for readability purposes
header("Content-Type: text/plain");
// save_and_display tree
echo $dom->saveXML();
?>
Çë×¢ÒâDOMÎĵµ¶ÔÏóµÄsaveXML()·½·¨¡£ÉÔºóÎÒÔÙÏêϸ½éÉÜÕâÒ»·½·¨£¬ÏÖÔÚÄãÖ»ÐèÒª¼òµ¥ÈÏʶµ½ËüÓÃÓÚÊä³öXMLÎĵµµÄµ±Ç°¿ìÕÕµ½Ò»¸öÎļþ»òä¯ÀÀÆ÷¡£ÔÚ±¾Àý£¬ÎªÔöÇ¿¿É¶ÁÐÔ£¬ÎÒÒѾ½«ASCIIÂëÎı¾Ö±½ÓÊä³öÖÁä¯ÀÀÆ÷¡£ÔÚʵ¼ÊÓ¦ÓÃÖУ¬¿É½«ÒÔtext/XMLÍ·Îļþ·¢Ë͵½ä¯ÀÀÆ÷¡£
ÈçÔÚä¯ÀÀÆ÷Öв鿴Êä³ö£¬Äã¿É¿´µ½ÈçÏ´úÂ룺
<?xml version="1.0"?>
Ìí¼ÓÔªËغÍÎı¾½Úµã
XMLÕæÕýÇ¿´óµÄ¹¦ÄÜÊÇÀ´×ÔÆäÔªËØÓë·â×°µÄÄÚÈÝ¡£ÐÒÔ˵ÄÊÇ£¬Ò»µ©Äã³õʼ»¯DOMÎĵµ£¬ºÜ¶à²Ù×÷±äµÃºÜ¼òµ¥¡£´Ë¹ý³Ì°üº¬ÈçÏÂÁ½²½Ö裺
¶ÔÏëÌí¼ÓµÄÿһԪËØ»òÎı¾½Úµã£¬Í¨¹ýÔªËØÃû»òÎı¾ÄÚÈݵ÷ÓÃDOMÎĵµ¶ÔÏóµÄcreateElement()»òcreateTextNode()·½·¨¡£Õ⽫´´½¨¶ÔÓ¦ÓÚÔªËØ»òÎı¾½ÚµãµÄжÔÏó¡£
ͨ¹ýµ÷ÓýڵãµÄappendChild()·½·¨£¬²¢°ÑÆä´«µÝ¸øÉÏÒ»²½Öд´½¨µÄ¶ÔÏ󣬲¢ÔÚXMLÎĵµÊ÷Öн«ÔªËØ»òÎı¾½ÚµãÌí¼Óµ½¸¸½Úµã¡£
ÒÔÏ·¶Àý½«Çå³þµØÑÝʾÕâ2²½Ö裬Çë²é¿´³ÌÐòÇåµ¥B¡£
³ÌÐòÇåµ¥ B
<?php
// create doctype
$dom = new DOMDocument("1.0");
// display document in browser as plain text
// for readability purposes
header("Content-Type: text/plain");
// create root element
$root = $dom->createElement("toppings");
$dom->appendChild($root);
// create child element
$item = $dom->createElement("item");
$root->appendChild($item);
// create text node
$text = $dom->createTextNode("pepperoni");
$item->appendChild($text);
// save_and_display tree
echo $dom->saveXML();
?>
ÕâÀÎÒÊ×ÏÈ´´½¨Ò»¸öÃû×ÖΪ<toppings>µÄ¸ùÔªËØ£¬²¢Ê¹Ëü¹éÓÚXMLÍ·ÎļþÖС£È»ºó£¬ÎÒ½¨Á¢ÃûΪ<item>µÄÔªËز¢Ê¹Ëü¹éÓÚ¸ùÔªËØ¡£×îºó£¬ÎÒÓÖ´´½¨Ò»¸öֵΪ“pepperoni”µÄÎı¾½Úµã²¢Ê¹Ëü¹éÓÚ<item>ÔªËØ¡£×îÖÕ½á¹ûÈçÏ£º
<?xml version="1.0"?>
<toppings>
?<
Ïà¹ØÎĵµ£º
°²×°
$cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin/';//phpMyAdminµÄ°²×°Â·¾¶
$cfg['blowfish_secret'] = '123456';//¼ÓÃÜÃܳף¬¿ÉËæÒâ¸ü¸Ä¡£
$cfg['Servers'][$i]['user'] = 'root'; // MySQLÓû§£¬Èç root
$cfg['Servers'][$i]['password'] = 'pswd'; // MySQLÓû§ÃÜÂë
$cfg['DefaultLang'] = '';¡¡¸ÄÎ ......
(4)Ó³ÉäÀà(ReflectionClass)
ReflectionClassÀàÔÊÐíÄã·´ÏòÓ³ÉäÀà¡£
<?
php
interface MySerializable
{
// ...}
class My
Object
{
// ...}
/** A counter class */
class
Counter
exten ......
In the directory where you plan to install Elgg, do the following:
Create the file .htaccess and add these two lines
RewriteEngine on
RewriteRule ^testing.php$ modrewrite.php
This tells the webserver to load modrewrite.php when testing.php is
requested.
In order to get this test to work on ......
¡¡¡¡¼ÌÐøѧϰD-Bus¡£Ö®Ç°Ñ§Ï°ÁËʹÓõײãµÄAPIÀ´·¢ËÍ£¬¼àÌýÏûÏ¢µÄ·½Ê½¡£ÔÚ
D-
Busѧϰ£¨ËÄ£©£º»ù´¡Ð¡Àý×Ó£¨Í¬²½ºÍÒì²½£©
Ö®ÖУ¬ÎÒÃǸø³öÁËÀûÓÃproxy½øÐз¢ËÍmethod_call£¬²¢µÈ´ýmethod_reply»òÕßerrorµÄclientÇé¿ö¡£ÔÚD-BusÖУ¬¿ÉÒÔ½«D-Bus½Ó¿Ú¶¨ÒåÓÃXML¸ñʽ±íÊö´¦Àí£¬²¢ÀûÓù¤¾ß£¬×Ô¶¯Éú³ÉÍ·Îļþ£¬¸ø³ö¹¤ÕûµÄµ÷Ó÷½Ê½¡ ......
Ò»¡¢¼òµ¥½éÉÜ
using System.Xml;
//³õʼ»¯Ò»¸öxmlʵÀý
XmlDocument xml=new XmlDocument();
//µ¼ÈëÖ¸¶¨xmlÎļþ
xml.Load(path);
xml.Load(HttpContext.Current.Server.MapPath("~/file/bookstore.xml"));
//Ö¸¶¨Ò»¸ö½Úµã
XmlNode root=xml.SelectSingleNode("/root");
//»ñÈ¡½ÚµãÏÂËùÓÐÖ±½Ó×Ó½Úµã
XmlNodeList ch ......