SimpleXML 可把 XML 文档转换为对象,比如:
当执行类似下列的基础任务时,SimpleXML 使用起来非常快捷:
<?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 $xml = simplexml_load_file("test.xml"); echo $xml->getName() . "<br />"; foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; } ?>
note to: George from: John heading: Reminder body: Don‘t forget the meeting!
原文:http://www.cnblogs.com/agang-php/p/4362298.html