X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP getName() Function

PHP SimpleXML Reference PHP SimpleXML Reference

Example

Return the name of the XML element and the children:

<?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>";
  }
?>

Run example »

Definition and Usage

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


Syntax

getName();

Technical Details

Return Value: Returns the name of the XML tag referenced by the SimpleXMLElement object, as a string
PHP Version: 5.1.3+


PHP SimpleXML Reference PHP SimpleXML Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook