Php/func simplexml getname
来自菜鸟教程
PHP getName()函数
例
返回XML元素和子元素的名称:
<?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);
// Get the name of the cars element
echo $sxe->getName() . "<br>";
// Also print out the names of the children of the cars element
foreach ($sxe->children() as $child)
{
echo $child->getName() . "<br>";
}
?>
定义和用法
getName()函数返回XML元素的名称。
句法
SimpleXMLElement::getName()
技术细节
| 返回值: | XML元素的名称,以字符串形式 |
| PHP版本: | 5.1.3+ |