Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP getName() Function

PHP getName() Function

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual

Example

Return the names of an XML element and its child elements:

Volvo

BMW

Saab

XML;

$sxe=new SimpleXMLElement($xml);

echo $sxe->getName() . "
";

foreach ($sxe->children() as $child)

{

echo $child->getName() . "
";

}

?>

Run Example »


Definition and Usage

The getName() function returns the name of an XML element.


Syntax

getName();

Technical Details

Return Value: Returns the name of the XML tag referenced by the SimpleXML element, as a string.
PHP Version: 5.1.3+

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual