downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/simplexmlelement.children.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/class.simplexmlelement.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'simplexmlelement.children.php',
   
1 => 'SimpleXMLElement::children',
  ),
 
'up' =>
  array (
   
0 => 'class.simplexmlelement.php',
   
1 => 'The SimpleXMLElement class',
  ),
 
'prev' =>
  array (
   
0 => 'simplexmlelement.attributes.php',
   
1 => 'SimpleXMLElement::attributes',
  ),
 
'next' =>
  array (
   
0 => 'simplexmlelement.construct.php',
   
1 => 'SimpleXMLElement::__construct',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="simplexmlelement.children" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SimpleXMLElement::children</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.0.1)</p><p class="refpurpose"><span class="refname">SimpleXMLElement::children</span> &mdash; <span class="dc-title">Finds children of given node</span></p>

 </div>
 
 <a name="simplexmlelement.children.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="classsynopsis">
   <div class="ooclass"><a href="class.simplexmlelement.php" class="classname">SimpleXMLElement</a></div>
   <div class="methodsynopsis dc-description">
    <span class="type">SimpleXMLElement</span> <span class="methodname"><b>children</b></span>
     ([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$ns</tt></span>
    [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$is_prefix</tt></span>
   ]] )</div>

  </div>
  <p class="para">
   This method finds the children of the element of which it is a member. The result
   follows normal iteration rules.
  </p>
  <blockquote><p><b class="note">Note</b>: <span class="simpara">SimpleXML has made a rule of adding
iterative properties to most methods. They cannot be viewed using <a href="function.var-dump.php" class="function">var_dump()</a>
or anything else which can examine objects.</span></p></blockquote>
 </div>


 <a name="simplexmlelement.children.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">ns</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">is_prefix</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Default to <b><tt class="constant">FALSE</tt></b>
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="simplexmlelement.children.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
  </p>
 </div>


 <a name="simplexmlelement.children.changelog"></a><div class="refsect1 changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   </p><table class="doctable informaltable">
   
     <thead valign="middle">
      <tr valign="middle">
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody valign="middle" class="tbody">
      <tr valign="middle">
       <td align="left">5.2.0</td>
       <td align="left">
        The optional parameter <i><tt class="parameter">is_prefix</tt></i>
 was added.
       </td>
      </tr>

     </tbody>
   
   </table>
<p>
  </p>
 </div>


 <a name="simplexmlelement.children.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 Traversing a <i>children()</i> pseudo-array</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$xml&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SimpleXMLElement</span><span style="color: #007700">(<br /></span><span style="color: #DD0000">'&lt;person&gt;<br />&nbsp;&lt;child&nbsp;role="son"&gt;<br />&nbsp;&nbsp;&lt;child&nbsp;role="daughter"/&gt;<br />&nbsp;&lt;/child&gt;<br />&nbsp;&lt;child&nbsp;role="daughter"&gt;<br />&nbsp;&nbsp;&lt;child&nbsp;role="son"&gt;<br />&nbsp;&nbsp;&nbsp;&lt;child&nbsp;role="son"/&gt;<br />&nbsp;&nbsp;&lt;/child&gt;<br />&nbsp;&lt;/child&gt;<br />&lt;/person&gt;'</span><span style="color: #007700">);<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">children</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$second_gen</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'&nbsp;The&nbsp;person&nbsp;begot&nbsp;a&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$second_gen</span><span style="color: #007700">[</span><span style="color: #DD0000">'role'</span><span style="color: #007700">];<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(</span><span style="color: #0000BB">$second_gen</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">children</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$third_gen</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'&nbsp;who&nbsp;begot&nbsp;a&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$third_gen</span><span style="color: #007700">[</span><span style="color: #DD0000">'role'</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">';'</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(</span><span style="color: #0000BB">$third_gen</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">children</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$fourth_gen</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'&nbsp;and&nbsp;that&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$third_gen</span><span style="color: #007700">[</span><span style="color: #DD0000">'role'</span><span style="color: #007700">]&nbsp;.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'&nbsp;begot&nbsp;a&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$fourth_gen</span><span style="color: #007700">[</span><span style="color: #DD0000">'role'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents para"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
The person begot a son who begot a daughter; The person
begot a daughter who begot a son; and that son begot a son
</pre></div>
    </div>
   </div><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites