===================================
===================================
<?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
if (file_exists('test.xml'))
{
$xml = simplexml_load_file('test.xml');
var_dump($xml);
print_r($xml); }
else
{
exit('Error.');
}
?>
=======================================================================
申明:以上两个例子来自于w3school....添加了print_r($xml);进行输出结果的对比
======================================================================
object(SimpleXMLElement)#1 (4)
{
["to"]=> string(6) "George"
["from"]=> string(4) "John"
["heading"]=> string(8) "Reminder"
["body"]=> string(25) "Don't forget the meeting!"
}
SimpleXMLElement Object
(
[to] => George
[from] => John
[heading] => Reminder
[body] => Don't forget the meeting!
)