Funzione PHP hasChildren()
Esempio
Controlla se l'elemento corrente ha figli, se ne ha; emetti l'elemento corrente:
<?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>";
}
}
?>
Definizione e utilizzo
La funzione hasChildren() controlla se l'elemento corrente ha figli.
Sintassi
SimpleXMLIterator::hasChildren()
Dettagli tecnici
Valore di ritorno: | TRUE se l'elemento corrente ha figli. FALSO altrimenti |
---|---|
Versione PHP: | 5.0+ |
❮ Riferimento PHP SimpleXML