Current Location: Home> Function Categories> getName

getName

Returns the name of the element.
Name:getName
Category:Uncategorized
Programming Language:php
One-line Description:Returns the name of the element.

Definition and usage

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

Example

Returns the names 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);
// Get the name of the cars element echo $sxe->getName() . " < br > ";

// At the same time output the name of the child element of the cars element foreach ($sxe->children() as $child)
  {
  echo $child->getName() . " < br > ";
  }
?>

Run the instance

grammar

 SimpleXMLElement :: getName ( )
Similar Functions
Popular Articles