Funkcja getName() PHP
Przykład
Zwróć nazwę elementu XML i dzieci:
<?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>";
}
?>
Definicja i użycie
Funkcja getName() zwraca nazwę elementu XML.
Składnia
SimpleXMLElement::getName()
Szczegóły techniczne
Wartość zwrotu: | Nazwa elementu XML w postaci ciągu znaków |
---|---|
Wersja PHP: | 5.1.3+ |
❮ Dokumentacja PHP SimpleXML