svn: /phpdoc/en/trunk/reference/simplexml/simplexmlelement/ children.xml

From: Date: Wed, 24 Feb 2010 12:23:28 +0000
Subject: svn: /phpdoc/en/trunk/reference/simplexml/simplexmlelement/ children.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-6128@lists.php.net to get a copy of this message
degeberg Wed, 24 Feb 2010 12:23:28 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=295463 Log: Should be the last fix to SimpleXMLElement::children(). Grammar fixes, documented parameters, added additional example. Changed paths: U phpdoc/en/trunk/reference/simplexml/simplexmlelement/children.xml Modified: phpdoc/en/trunk/reference/simplexml/simplexmlelement/children.xml =================================================================== --- phpdoc/en/trunk/reference/simplexml/simplexmlelement/children.xml 2010-02-24 11:47:16 UTC (rev 295462) +++ phpdoc/en/trunk/reference/simplexml/simplexmlelement/children.xml 2010-02-24 12:23:28 UTC (rev 295463) @@ -13,12 +13,12 @@ <methodsynopsis> <type>SimpleXMLElement</type><methodname>children</methodname> <methodparam choice="opt"><type>string</type><parameter>ns</parameter></methodparam> - <methodparam choice="opt"><type>bool</type><parameter>is_prefix</parameter></methodparam> + <methodparam choice="opt"><type>bool</type><parameter>is_prefix</parameter><initializer>false</initializer></methodparam> </methodsynopsis> </classsynopsis> <para> - This method finds the children of the element of which it is a member. The result - follows normal iteration rules. + This method finds the children of an element. The result follows normal + iteration rules. </para> &simplexml.iteration; </refsect1> @@ -31,6 +31,7 @@ <term><parameter>ns</parameter></term> <listitem> <para> + An <acronym>XML</acronym> namespace. </para> </listitem> </varlistentry> @@ -38,7 +39,10 @@ <term><parameter>is_prefix</parameter></term> <listitem> <para> - Default to &false; + If <parameter>ns_prefix</parameter> is &true;, + <parameter>ns</parameter> will be regarded as a namespace + <acronym>URL</acronym>. If &false;, <parameter>ns</parameter> will be + regarded as a prefix. </para> </listitem> </varlistentry> @@ -50,7 +54,7 @@ &reftitle.returnvalues; <para> Returns a <classname>SimpleXMLElement</classname> element, whether the node - have children or not. + has children or not. </para> </refsect1> @@ -121,6 +125,46 @@ ]]> </screen> </example> + <example> + <title>Using namespaces</title> + <programlisting role="php"> +<![CDATA[ +<?php +$xml = '<example xmlns:foo="my.foo.urn"> + <foo:a>Apple</foo:a> + <foo:b>Banana</foo:b> + <c>Cherry</c> +</example>'; + +$sxe = new SimpleXMLElement($xml); + +$kids = $sxe->children('foo'); +var_dump(count($kids)); + +$kids = $sxe->children('foo', TRUE); +var_dump(count($kids)); + +$kids = $sxe->children('my.foo.urn'); +var_dump(count($kids)); + +$kids = $sxe->children('my.foo.urn', TRUE); +var_dump(count($kids)); + +$kids = $sxe->children(); +var_dump(count($kids)); +?> +]]> + </programlisting> + <screen> +<![CDATA[ +int(0) +int(2) +int(2) +int(0) +int(1) +]]> + </screen> + </example> </para> </refsect1> @@ -129,7 +173,7 @@ <simpara> <methodname>SimpleXMLElement::children</methodname> returns a node - object no matter if the current node have children or not. Use + object no matter if the current node has children or not. Use <function>count</function> on the return value to see if there are any children. </simpara>

« previous php.doc.cvs (#6128) next »