<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = 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 => 'it',
  ),
  'this' => 
  array (
    0 => 'simplexmlelement.children.php',
    1 => 'SimpleXMLElement::children',
    2 => 'Finds children of given node',
  ),
  'up' => 
  array (
    0 => 'class.simplexmlelement.php',
    1 => 'SimpleXMLElement',
  ),
  'prev' => 
  array (
    0 => 'simplexmlelement.attributes.php',
    1 => 'SimpleXMLElement::attributes',
  ),
  'next' => 
  array (
    0 => 'simplexmlelement.construct.php',
    1 => 'SimpleXMLElement::__construct',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/simplexml/simplexmlelement/children.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

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

 </div>
 
 <div class="refsect1 description" id="refsect1-simplexmlelement.children-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SimpleXMLElement::children</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$namespaceOrPrefix</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$isPrefix</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.simplexmlelement.php" class="type SimpleXMLElement">SimpleXMLElement</a></span></span></div>

  <p class="para rdfs-comment">
   This method finds the children of an element. The result follows normal
   iteration rules.
  </p>
  <blockquote class="note"><p><strong class="note">Nota</strong>: <span class="simpara">SimpleXML possiede regole per aggiungere proprietà iterative 
a diversi metodi. Queste non possono essere visualizzate con <span class="function"><a href="function.var-dump.php" class="function">var_dump()</a></span>
o qualsiasi altra cosa che possa esaminare gli oggetti.</span></p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-simplexmlelement.children-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">namespaceOrPrefix</code></dt>
     <dd>
      <p class="para">
       An <abbr title="eXtensible Markup Language">XML</abbr> namespace.
      </p>
     </dd>
    
    
     <dt><code class="parameter">isPrefix</code></dt>
     <dd>
      <p class="para">
       If <code class="parameter">isPrefix</code> is <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>,
       <code class="parameter">namespaceOrPrefix</code> will be regarded as a prefix. If <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>,
       <code class="parameter">namespaceOrPrefix</code> will be regarded as a namespace
       <abbr title="Uniform Resource Locator">URL</abbr>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-simplexmlelement.children-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Returns a <span class="classname"><a href="class.simplexmlelement.php" class="classname">SimpleXMLElement</a></span> element, whether the node 
   has children or not, unless the node represents an attribute, in which case
   <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> is returned.
  </p>
 </div>


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

    <div class="example-contents"><p>Il precedente esempio visualizzerà:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">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>
   <div class="example" id="example-2">
    <p><strong>Example #2 Using namespaces</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$xml </span><span style="color: #007700">= </span><span style="color: #DD0000">'&lt;example xmlns:foo="my.foo.urn"&gt;<br />  &lt;foo:a&gt;Apple&lt;/foo:a&gt;<br />  &lt;foo:b&gt;Banana&lt;/foo:b&gt;<br />  &lt;c&gt;Cherry&lt;/c&gt;<br />&lt;/example&gt;'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$sxe </span><span style="color: #007700">= new </span><span style="color: #0000BB">SimpleXMLElement</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$kids </span><span style="color: #007700">= </span><span style="color: #0000BB">$sxe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">children</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$kids</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$kids </span><span style="color: #007700">= </span><span style="color: #0000BB">$sxe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">children</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">, </span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$kids</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$kids </span><span style="color: #007700">= </span><span style="color: #0000BB">$sxe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">children</span><span style="color: #007700">(</span><span style="color: #DD0000">'my.foo.urn'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$kids</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$kids </span><span style="color: #007700">= </span><span style="color: #0000BB">$sxe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">children</span><span style="color: #007700">(</span><span style="color: #DD0000">'my.foo.urn'</span><span style="color: #007700">, </span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$kids</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$kids </span><span style="color: #007700">= </span><span style="color: #0000BB">$sxe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">children</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$kids</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">int(0)
int(2)
int(2)
int(0)
int(1)</pre>
</div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-simplexmlelement.children-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="simplexmlelement.count.php" class="methodname" rel="rdfs-seeAlso">SimpleXMLElement::count()</a> - Counts the children of an element</span></li>
    <li><span class="function"><a href="function.count.php" class="function" rel="rdfs-seeAlso">count()</a> - Conta gli elementi in una variabile, o le propriet&agrave; in un oggetto</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>