Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÈçºÎʹÓÃPHP DOMDocument´´½¨¶¯Ì¬XMLÎļþ


µ±´¦Àí»ùÓÚXMLÓ¦ÓóÌÐòʱ£¬¿ª·¢Õß¾­³£ÐèÒª½¨Á¢XML±àÂëÊý¾Ý½á¹¹¡£ÀýÈ磬WebÖлùÓÚÓû§ÊäÈëµÄXML״̬ģ°å£¬·þÎñÆ÷ÇëÇóXMLÓï¾ä£¬ÒÔ¼°»ùÓÚÔËÐÐʱ¼ä²ÎÊýµÄ¿Í»§ÏìÓ¦¡£
¾¡¹ÜXMLÊý¾Ý½á¹¹µÄ¹¹½¨±È½Ï·Ñʱ£¬µ«Èç¹ûʹÓóÉÊìµÄPHP DOMÓ¦ÓóÌÐò½Ó¿Ú£¬Ò»Çж¼»á±äµÃ¼òµ¥Ã÷ÁË¡£±¾ÎĽ«ÏòÄã½éÉÜ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");
$


Ïà¹ØÎĵµ£º

PHP±à³ÌµÄÏȽø¼¼Êõ

ËäÈ»PHPÌṩÁ˺ܶ๦ÄÜÎÒÃÇ£¬µ«ÓÐЩÊÂÇ黹ûÓд¦ÀíÕâЩ·Ç³£·½±ã¡£ÀýÈ磬PHPÌṩµÄÈÕÆÚ¹¦ÄÜ£¬Ê±¼äºÜÓÐÏÞ¡£ MySQLÒѾ­ÌṩÁËÐí¶àÎÒÃÇÕâЩ¹¦ÄÜ¡£ÎÒ¿ÉÒÔʹÓÃMySQLº¯ÊýÀ´´¦ÀíPHPµÄ¹ý³Ì£¿ÎÒÔÚÏÂÃæµÄ³¢ÊÔ¡£
“£¿ PHPµÄ
$ data_time =“1998-12-31 23:59:59”;
$ connect_id = mysql_connect£¨'±¾µØÖ÷»ú'£©;
......

¶þ½øÖÆȨÏÞ¿ØÖÆPHPÀà

<?php
/* ¶þ½øÖÆȨÏÞ¿ØÖÆPHPÀà
* ×÷ Õß: ¶à²ËÄñ
* ÓÊ Ïä: kingerq AT QQ DOT com
* À´ Ô´£ºhttp://blog.csdn.net/kingerq/archive/2009/10/22/4714223.aspx
* ´´½¨Ê±¼ä: 2009-10-22
*/
class binPower{

var $power = "";
//ȨÏÞ´æÖü±äÁ¿,Ê®½øÖÆÕûÊý

function __construct($power) ......

PHP±í´ïʽÓëÔËËã·û

PHP±í´ïʽ
±í´ïʽÊdz£Á¿¡¢±äÁ¿ºÍÔËËã·ûµÄ×éºÏ
±í´ïʽÊÇPHPÖеÄÖØÒªÄÚÈÝ£¬PHPÖм¸ºõËùÓеĶ«Î÷¶¼¿ÉÒÔ³ÆΪ±í´ïʽ
$x=10;
$y=($x=10);
$y+=($x=10);
$z=&$x;
$condition?$true_item:$false_item;
PHPÔËËã·û
ÔËËã·ûÊÇÓÃÀ´¶ÔÊýÖµ»ò±äÁ¿½øÐÐijÖÖ²Ù×÷ÔËËãµÄ·ûºÅ¡£Ò»°ãµØ˵£¬ÔËËã·û¿ÉÒÔ´øÓÐ1¸ö¡¢2¸ö»òÕ߸ü¶à¸öÔËË ......

PHPÍⲿ±äÁ¿Óë»·¾³±äÁ¿

PHPÍⲿ±äÁ¿Óë»·¾³±äÁ¿
PHPµÄÌصãÖ®Ò»¾ÍÊÇ¿ÉÒÔÓüòµ¥µÄ·½Ê½´¦Àí±íµ¥Êý¾Ý£¬»ñÈ¡»·¾³±äÁ¿¡£ÔÚPHPÖУ¬ÕâЩÍⲿÊý¾Ý»ò±äÁ¿±£´æÔÚÒ»ÖÖÌØÊâµÄÈ«¾Ö±äÁ¿Êý×éÖС£
±íµ¥Êý¾Ý
$_GET£º»ñÈ¡GETÇëÇó·¢Ë͵ÄÊý¾Ý
$_POST£º»ñÈ¡POSTÇëÇó·¢Ë͵ÄÊý¾Ý
$_REQUEST£º¿ÉÒÔͬʱ»ñÈ¡GETºÍPOSTÇëÇó·¢Ë͵ÄÊý¾Ý
¡¾Ê¾Àý¡¿
ÇëÇóURL£ºhttp://localh ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ