PHP hasChildren() Funktion
Beispiel
Überprüft, ob das aktuelle Element Kinder hat, falls ja; Ausgabe des aktuellen Elements:
<?php
$bookxml = <<<XML
<bookstore>
<book>
<title>Everyday Italian</title>
<author>Giada De
Laurentiis</author>
</book>
<book>
<title>Harry Potter</title>
<author>J K.
Rowling</author>
</book>
<book>
<title>Learning XML</title>
<author>Erik T. Ray</author>
</book>
</bookstore>
XML;
$xml = new SimpleXMLIterator($bookxml);
for( $xml->rewind(); $xml->valid(); $xml->next() ) {
if($xml->hasChildren())
{
var_dump($xml->current());
echo
"<br>";
}
}
?>
Definition und Verwendung
Die Funktion hasChildren() prüft, ob das aktuelle Element Kinder hat.
Syntax
SimpleXMLIterator::hasChildren()
Technische Details
Rückgabewert: | TRUE, wenn das aktuelle Element untergeordnete Elemente hat. Ansonsten FALSCH |
---|---|
PHP-Version: | 5.0+ |
❮ PHP-SimpleXML-Referenz