mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-24 12:58:56 +00:00

# thanks, tk AT bytecrash DOT net git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@163571 c90b9560-bf6c-de11-be94-00142212c4b1
85 lines
2.1 KiB
XML
85 lines
2.1 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.5 $ -->
|
|
<refentry id='function.simplexml-element-children'>
|
|
<refnamediv>
|
|
<refname>SimpleXMLElement->children</refname>
|
|
<refpurpose>
|
|
Finds children of given node.
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>object SimpleXMLElement</type><methodname>simplexml_element->children</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<para>
|
|
This method finds the children of the element of which it is a member. The result
|
|
follows normal iteration rules.
|
|
</para>
|
|
&simplexml.iteration;
|
|
<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>
|
|
|
|
<!-- 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
|
|
-->
|