From 80cbff1fc0a43445b88a199eeadc17d10cec39fd Mon Sep 17 00:00:00 2001 From: Daniel Egeberg Date: Wed, 24 Feb 2010 12:23:28 +0000 Subject: [PATCH] Should be the last fix to SimpleXMLElement::children(). Grammar fixes, documented parameters, added additional example. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@295463 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../simplexml/simplexmlelement/children.xml | 56 +++++++++++++++++-- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/reference/simplexml/simplexmlelement/children.xml b/reference/simplexml/simplexmlelement/children.xml index cf312177de..144972659e 100644 --- a/reference/simplexml/simplexmlelement/children.xml +++ b/reference/simplexml/simplexmlelement/children.xml @@ -13,12 +13,12 @@ SimpleXMLElementchildren stringns - boolis_prefix + boolis_prefixfalse - 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. &simplexml.iteration; @@ -31,6 +31,7 @@ ns + An XML namespace. @@ -38,7 +39,10 @@ is_prefix - Default to &false; + If ns_prefix is &true;, + ns will be regarded as a namespace + URL. If &false;, ns will be + regarded as a prefix. @@ -50,7 +54,7 @@ &reftitle.returnvalues; Returns a SimpleXMLElement element, whether the node - have children or not. + has children or not. @@ -118,6 +122,46 @@ foreach ($xml->children() as $second_gen) { + + + + Using namespaces + + + Apple + Banana + Cherry +'; + +$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)); +?> +]]> + + + @@ -129,7 +173,7 @@ begot a daughter who begot a son; and that son begot a son SimpleXMLElement::children 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 count on the return value to see if there are any children.