kennyt Mon Jan 26 15:24:39 2004 EDT
Modified files: /phpdoc/en/reference/simplexml/functions simplexml-element-children.xml Log: "function" -> "method"; and added example of children() usage. http://cvs.php.net/diff.php/phpdoc/en/reference/simplexml/functions/simplexml-element-children.xml?r1=1.1&r2=1.2&ty=u Index: phpdoc/en/reference/simplexml/functions/simplexml-element-children.xml diff -u phpdoc/en/reference/simplexml/functions/simplexml-element-children.xml:1.1 phpdoc/en/reference/simplexml/functions/simplexml-element-children.xml:1.2 --- phpdoc/en/reference/simplexml/functions/simplexml-element-children.xml:1.1 Fri Jan 23 11:17:17 2004 +++ phpdoc/en/reference/simplexml/functions/simplexml-element-children.xml Mon Jan 26 15:24:39 2004 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id='function.simplexml-element-children'> <refnamediv> <refname>simplexml_element->children</refname> @@ -14,9 +14,59 @@ <void/> </methodsynopsis> <para> - This function finds the children of the element of which it is a member. The result + This method finds the children of the element of which it is a member. The result follows normal iteration rules. </para> + <note> + <simpara> + Like most other SimpleXML methods, <literal>children()</literal> + has iterative properties which cannot be viewed using + <function>var_dump</function> or anything else which can examine + objects. + </simpara> + </note> + <example> + <title>Traversing a <literal>children()</literal> pseudo-array</title> + <programlisting role="php"> +<![CDATA[ +<?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']; + } + } +} +?> +]]> + </programlisting> + <simpara> + This script will output: + </simpara> + <screen> +<![CDATA[ +The person begot a son who begot a daughter; The person +begot a daughter who begot a son; and that son begot a son +]]> + </screen> + </example> </refsect1> </refentry>