PHP hasChildren() Functie
Voorbeeld
Controleert of het huidige element kinderen heeft, indien dit het geval is; voer het huidige element uit:
<?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>";
}
}
?>
Definitie en gebruik
De functie hasChildren() controleert of het huidige element kinderen heeft.
Syntaxis
SimpleXMLIterator::hasChildren()
Technische details
Winstwaarde: | TRUE als het huidige element kinderen heeft. ONWAAR anders |
---|---|
PHP-versie: | 5.0+ |
❮ PHP SimpleXML-referentie