PHP getName () function
PHP SimpleXML Reference Manual
Examples
Returns the name of the XML element and its child elements:
<?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>";
}
?>
$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>";
}
?>
Running instance »
Definition and Usage
getName () function returns the name of the XML element.
grammar
getName();
technical details
return value: | Returns a string SimpleXML element references the name of the XML tags. |
---|---|
PHP version: | 5.1.3+ |
PHP SimpleXML Reference Manual