SimpleXMLElement->attributes
<<<
SimpleXMLElement->children SimpleXMLElement->xpath
>>>

8.111 Fonctions SimpleXML
8 Référence des fonctions
 Manuel PHP

Introduction
Pré-requis
Installation
Exemples
Constantes pré-définies
SimpleXMLElement->asXML
SimpleXMLElement->attributes
->SimpleXMLElement->children
SimpleXMLElement->xpath
simplexml_import_dom
simplexml_load_file
simplexml_load_string

8.111.8 SimpleXMLElement->children()Trouve les enfants d'une node

[ Exemples avec simplexml_element_children ]   CVS uniquement

SimpleXMLElement  simplexml_element->children ( void )

Cette méthode trouve le fils de l'élément dont il est membre. Le résultat suit les règles normales d'itération.

Note

SimpleXML ajoute des propriétés itératives pour presque toutes ses méthodes. Celles-ci ne peuvent être vues en utilisant var_dump ou tout autre fonction qui examine les objets.

Traverser un pseudo-tableau children()

<?php
$xml
= simplexml_load_string(
'<person>
<child role="son">
  <child role="daughter"/>
</child>
<child role="daughter">
  <child role="son">
   <child role="son"/>
  </child>
</child>
</person>'
);

foreach (
$xml->children() as $second_gen) {
    echo
' The person begot a ' . $second_gen['role'];

    foreach (
$second_gen->children() as $third_gen) {
        echo
' who begot a ' . $third_gen['role'] . ';';
    
        foreach (
$third_gen->children() as $fourth_gen) {
            echo
' and that ' . $third_gen['role'] .
                
' begot a ' . $fourth_gen['role'];
        }
    }
}
?>

<< SimpleXMLElement->children >>
SimpleXMLElement->attributes Fonctions SimpleXML SimpleXMLElement->xpath