我打算从xml文件中提取某些数据。我用simple_load_file()
加载一个XML文件并获取对象元素,但我不知道如何访问它们。 XML文件就像下面:如何在使用`simple_load_file()`加载xml文件后访问元素
<?mxl version="1.0">
<metaData>
<Application version="1.0" type="32">
<options>
<section name="A">
<description>...</description>
...
<section name="B">
....
</options>
</Application>
</metaData>
我的代码:
$xml = simplexml_load_file($url);
echo $xml->Application->version; // get the version but failed
echo $xml->Application->options->section...//I want to get the data from each section, but I don't know how to visit the elements.
自己调试'print_r($ xml)'。 [PHP手册也很棒](http://php.net/manual/en/function.simplexml-load-file.php) – Peter
应该不太好用 – insanebits
你可以试试$ xml-> Application ['version' ] – insanebits