App下载

demo_func_simplexml_getname 在线工具

demo_func_simplexml_getname 在线工具

<?php
$xml=<<<XML
<FONT COLOR=#ff0000><?xml version="1.0" standalone="yes"?></FONT>
<cars>
&nbsp;&nbsp;  <car id="1">Volvo</car>
&nbsp;&nbsp;  <car id="2">BMW</car>
&nbsp;&nbsp;  <car id="3">Saab</car>    
</cars>
XML;
&nbsp; 
$sxe=new SimpleXMLElement($xml);
echo $sxe->getName() . "<br>";

foreach ($sxe->children() as $child)
&nbsp;&nbsp;  {
&nbsp;&nbsp;  echo $child->getName() . "<br>";
&nbsp;&nbsp;  }
?>
运行结果