2004-01-23 16:17:17 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-01-30 23:38:06 +00:00
|
|
|
<!-- $Revision: 1.3 $ -->
|
2004-01-23 16:17:17 +00:00
|
|
|
<refentry id='function.simplexml-element-children'>
|
|
|
|
<refnamediv>
|
|
|
|
<refname>simplexml_element->children</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Finds children of given node.
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>object simplexml_element</type><methodname>simplexml_element->children</methodname>
|
|
|
|
<void/>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
2004-01-26 20:24:39 +00:00
|
|
|
This method finds the children of the element of which it is a member. The result
|
2004-01-23 16:17:17 +00:00
|
|
|
follows normal iteration rules.
|
|
|
|
</para>
|
2004-01-26 20:24:39 +00:00
|
|
|
<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>');
|
|
|
|
|
2004-01-30 23:38:06 +00:00
|
|
|
foreach ($xml->children() as $second_gen) {
|
|
|
|
echo ' The person begot a ' . $second_gen['role'];
|
2004-01-26 20:24:39 +00:00
|
|
|
|
2004-01-30 23:38:06 +00:00
|
|
|
foreach ($second_gen->children() as $third_gen) {
|
|
|
|
echo ' who begot a ' . $third_gen['role'] . ';';
|
2004-01-26 20:24:39 +00:00
|
|
|
|
2004-01-30 23:38:06 +00:00
|
|
|
foreach ($third_gen->children() as $fourth_gen) {
|
|
|
|
echo ' and that ' . $third_gen['role'] .
|
|
|
|
' begot a ' . $fourth_gen['role'];
|
2004-01-26 20:24:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</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>
|
2004-01-23 16:17:17 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|