简单教程
提交运行
代码编辑器:
<?php $xml=<<<XML <?xml version="1.0" standalone="yes"?> <cars> <car id="1">Volvo</car> <car id="2">BMW</car> <car id="3">Saab</car> </cars> XML; $sxe=new SimpleXMLElement($xml); echo $sxe->getName() , "<br>"; foreach ($sxe->children() as $child) { echo $child->getName() , "<br>"; }
运行结果: