1.简述
simplexml_load_file() 函数把 XML 文档载入对象中。
2.例子
<?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);
}
?>
object(SimpleXMLElement)#1 (4)
{
["to"]=> string(4) "George"
["from"]=> string(4) "John"
["heading"]=> string(8) "Reminder"
["body"]=> string(29) "Don't forget the meeting!"
}