<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'simplexmlelement.children.php',
    1 => 'SimpleXMLElement::children',
    2 => 'Findet Kindelemente des gegebenen Knotens',
  ),
  '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' => 'de',
    '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">Findet Kindelemente des gegebenen Knotens</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-simplexmlelement.children-description">
  <h3 class="title">Beschreibung</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">
   Die Methode findet Kinder eines Elements. Das Ergebnis entspricht den
   normalen Iterierungsregeln.
  </p>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: <span class="simpara">SimpleXML definiert für die
meisten Methoden Regeln für das Hinzufügen von iterativen Eigenschaften. Diese
können weder mit <span class="function"><a href="function.var-dump.php" class="function">var_dump()</a></span> oder auf andere Weise angezeigt
werden.</span></p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-simplexmlelement.children-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">namespaceOrPrefix</code></dt>
     <dd>
      <p class="para">
       Ein <abbr title="eXtensible Markup Language">XML</abbr>-Namensraum.
      </p>
     </dd>
    
    
     <dt><code class="parameter">isPrefix</code></dt>
     <dd>
      <p class="para">
       Ist <code class="parameter">isPrefix</code> <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, dann wird
       <code class="parameter">namespaceOrPrefix</code> als Prefix interpretiert. Ist
       es <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, dann wird <code class="parameter">namespaceOrPrefix</code> als
       Namensraum-<abbr title="Uniform Resource Locator">URL</abbr> interpretiert.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-simplexmlelement.children-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt ein <span class="classname"><a href="class.simplexmlelement.php" class="classname">SimpleXMLElement</a></span>-Objekt zurück, unabhängig
   davon, ob der Knoten Kindknoten hat oder nicht, außer der Knoten stellt ein
   Attribut dar, denn in diesem Fall wird <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> zurückgegeben.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-simplexmlelement.children-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
  <div class="example" id="example-1">
   <p><strong>Beispiel #1 Ein <code class="literal">children()</code>-Pseudo-Array durchlaufen</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="Sohn"&gt;<br />  &lt;child role="Tochter"/&gt;<br /> &lt;/child&gt;<br /> &lt;child role="Tochter"&gt;<br />  &lt;child role="Sohn"&gt;<br />   &lt;child role="Sohn"/&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">' Die Person zeugte eine/n ' </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">', die/der eine/n ' </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">' zeugte;'</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">' und diese/r ' </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">' zeugte eine/n ' </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>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Die Person zeugte eine/n Sohn, die/der eine/n Tochter zeugte; Die Person zeugte
 eine/n Tochter, die/der eine/n Sohn zeugte; und diese/r Sohn zeugte eine/n Sohn</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>Beispiel #2 Arbeiten mit Namensräumen</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;Apfel&lt;/foo:a&gt;<br />  &lt;foo:b&gt;Banane&lt;/foo:b&gt;<br />  &lt;c&gt;Kirsche&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">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="simplexmlelement.count.php" class="methodname" rel="rdfs-seeAlso">SimpleXMLElement::count()</a> - Z&auml;hlt die Anzahl der Kinder eines Elements</span></li>
    <li><span class="function"><a href="function.count.php" class="function" rel="rdfs-seeAlso">count()</a> - Z&auml;hlt alle Elemente eines Arrays oder eines Countable-Objekts</span></li>
   </ul>
  </p>
 </div>


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