PHP asXML() º¯Êý
¶¨ÒåºÍÓ÷¨
asXML() º¯ÊýÒÔ×Ö·û´®µÄÐÎʽ´Ó SimpleXMLElement ¶ÔÏó·µ»Ø XML Îĵµ¡£
Èôʧ°Ü£¬Ôò·µ»Ø false¡£
Óï·¨
class SimpleXMLElement
{
string asXML(file)
}
| ²ÎÊý | ÃèÊö |
|---|---|
| file | ¿ÉÑ¡¡£Èç¹û¹æ¶¨Á˴˲ÎÊý£¬Ôò¸Ãº¯Êý»á°Ñ XML дÈëÒ»¸öÎļþ£¬¶ø²»ÊÇ·µ»ØËü¡£ |
Àý×Ó
XML Îļþ£º
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
PHP ´úÂ룺
<?php
if (file_exists('test.xml'))
{
$xml = simplexml_load_file('test.xml');
}
echo $xml->asXML();
?>
Êä³ö£º
George John Reminder Don't forget the meeting!
Èç¹ûÔÚä¯ÀÀÆ÷´°¿ÚÖÐÑ¡Ôñ¡°²é¿´Ô´Îļþ¡±£¬»á¿´µ½ÕâЩ HTML£º
<note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>