From 9acefba1c2377dc2b1c9fdc42888887047a1351c Mon Sep 17 00:00:00 2001 From: Juliette Date: Sun, 12 Apr 2009 00:23:21 +0000 Subject: [PATCH] Documenting SimpleXMLIterator git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@278606 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/spl/simplexmliterator.xml | 4 +- reference/spl/simplexmliterator/current.xml | 42 ++++++++++++--- .../spl/simplexmliterator/getchildren.xml | 50 ++++++++++++++--- .../spl/simplexmliterator/haschildren.xml | 54 ++++++++++++++++--- reference/spl/simplexmliterator/key.xml | 39 ++++++++++++-- reference/spl/simplexmliterator/next.xml | 39 ++++++++++++-- reference/spl/simplexmliterator/rewind.xml | 38 +++++++++++-- reference/spl/simplexmliterator/valid.xml | 34 +++++++++--- 8 files changed, 259 insertions(+), 41 deletions(-) diff --git a/reference/spl/simplexmliterator.xml b/reference/spl/simplexmliterator.xml index 712782f629..85f567aaae 100644 --- a/reference/spl/simplexmliterator.xml +++ b/reference/spl/simplexmliterator.xml @@ -1,5 +1,5 @@ - + The SimpleXMLIterator class SimpleXMLIterator @@ -10,7 +10,7 @@
&reftitle.intro; - ... + The SimpleXMLIterator provides recursive iteration over all nodes of a SimpleXMLElement object.
diff --git a/reference/spl/simplexmliterator/current.xml b/reference/spl/simplexmliterator/current.xml index 7ba652f28a..f836c16985 100644 --- a/reference/spl/simplexmliterator/current.xml +++ b/reference/spl/simplexmliterator/current.xml @@ -1,9 +1,9 @@ - + SimpleXMLIterator::current - Return current SimpleXML entry + Returns the current element &reftitle.description; @@ -11,9 +11,9 @@ mixedSimpleXMLIterator::current - - &warn.undocumented.func; - + + This method returns the current element as a SimpleXMLIterator object or &null;. + @@ -24,7 +24,37 @@ &reftitle.returnvalues; - The current SimpleXML entry. + Returns the current element as a SimpleXMLIterator object or &null; on failure. + + + + + &reftitle.examples; + + + Return the current element + +PHP basicsXML basics'); +var_dump($xmlIterator->current()); + +$xmlIterator->rewind(); // rewind to first element +var_dump($xmlIterator->current()); +?> +]]> + + &example.outputs; + + + string(10) "PHP basics" +} +]]> + + diff --git a/reference/spl/simplexmliterator/getchildren.xml b/reference/spl/simplexmliterator/getchildren.xml index 3d470d6ea5..7a8e7b7d9b 100644 --- a/reference/spl/simplexmliterator/getchildren.xml +++ b/reference/spl/simplexmliterator/getchildren.xml @@ -1,9 +1,9 @@ - + SimpleXMLIterator::getChildren - Returns an iterator for the current entry if it is a SimpleXML object + Returns a SimpleXMLIterator object containing the sub-elements of the current element &reftitle.description; @@ -11,9 +11,9 @@ objectSimpleXMLIterator::getChildren - - &warn.undocumented.func; - + + This method returns a SimpleXMLIterator object containing the sub-elements of the current SimpleXMLIterator element. + @@ -24,7 +24,45 @@ &reftitle.returnvalues; - An iterator for the current entry, if it is a SimpleXML object. + Returns a SimpleXMLIterator object containing the sub-elements of the current element. + + + + + &reftitle.examples; + + + Return the sub-elements of the current element + + + + PHP Basics + Jim Smith + + XML basics + +XML; + +$xmlIterator = new SimpleXMLIterator($xml); +for( $xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next() ) { + foreach($xmlIterator->getChildren() as $name => $data) { + echo "The $name is '$data' from the class " . get_class($data) . "\n"; + } +} +?> +]]> + + &example.outputs; + + + + diff --git a/reference/spl/simplexmliterator/haschildren.xml b/reference/spl/simplexmliterator/haschildren.xml index b54d409cbd..736648d270 100644 --- a/reference/spl/simplexmliterator/haschildren.xml +++ b/reference/spl/simplexmliterator/haschildren.xml @@ -1,9 +1,9 @@ - + SimpleXMLIterator::hasChildren - Returns whether current entry is a SimpleXML object + Checks whether the current element has sub elements. &reftitle.description; @@ -11,9 +11,9 @@ boolSimpleXMLIterator::hasChildren - - &warn.undocumented.func; - + + This method checks whether the current SimpleXMLIterator element has sub-elements. + @@ -24,7 +24,49 @@ &reftitle.returnvalues; - &true; if the current entry is a SimpleXML object, otherwise &false; + &true; if the current element has sub-elements, otherwise &false; + + + + + &reftitle.examples; + + + Check whether the current element has sub-elements + + + + PHP Basics + Jim Smith + + XML basics + +XML; + +$xmlIterator = new SimpleXMLIterator( $xml ); +for( $xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next() ) { + if($xmlIterator->hasChildren()) { + var_dump($xmlIterator->current()); + } +} +?> +]]> + + &example.outputs; + + + string(10) "PHP Basics" + ["author"]=> + string(9) "Jim Smith" +} +]]> + + diff --git a/reference/spl/simplexmliterator/key.xml b/reference/spl/simplexmliterator/key.xml index 1dd6551f28..d72979c4e2 100644 --- a/reference/spl/simplexmliterator/key.xml +++ b/reference/spl/simplexmliterator/key.xml @@ -1,9 +1,9 @@ - + SimpleXMLIterator::key - Return current SimpleXML key + Return current key &reftitle.description; @@ -11,8 +11,9 @@ mixedSimpleXMLIterator::key - - &warn.undocumented.func; + + This method gets the XML tag name of the current element. + @@ -24,7 +25,35 @@ &reftitle.returnvalues; - The current SimpleXML key. + Returns the XML tag name of the element referenced by the current SimpleXMLIterator object or &false; + + + + + &reftitle.examples; + + + Get the current XML tag key + +PHP basicsXML basics'); + +echo var_dump($xmlIterator->key()); +$xmlIterator->rewind(); // rewind to the first element +echo var_dump($xmlIterator->key()); + +?> +]]> + + &example.outputs; + + + + diff --git a/reference/spl/simplexmliterator/next.xml b/reference/spl/simplexmliterator/next.xml index fb78ca9d1b..1534b58f0d 100644 --- a/reference/spl/simplexmliterator/next.xml +++ b/reference/spl/simplexmliterator/next.xml @@ -1,9 +1,9 @@ - + SimpleXMLIterator::next - Move to next entry + Move to next element &reftitle.description; @@ -11,9 +11,9 @@ voidSimpleXMLIterator::next - - &warn.undocumented.func; - + + This method moves the SimpleXMLIterator to the next element. + @@ -28,6 +28,35 @@ + + &reftitle.examples; + + + Move to the next element + +PHP BasicsXML basics'); +$xmlIterator->rewind(); // rewind to the first element +$xmlIterator->next(); + +var_dump($xmlIterator->current()); +?> +]]> + + &example.outputs; + + + string(10) "XML basics" +} +]]> + + + + + + SimpleXMLIterator::rewind - Rewind SimpleXML back to the start + Rewind to the first element &reftitle.description; @@ -11,9 +11,9 @@ voidSimpleXMLIterator::rewind - - &warn.undocumented.func; - + + This method rewinds the SimpleXMLIterator to the first element. + @@ -28,6 +28,34 @@ + + &reftitle.examples; + + + Rewind to the first element + +PHP BasicsXML Basics'); +$xmlIterator->rewind(); + +var_dump($xmlIterator->current()); +?> +]]> + + &example.outputs; + + + string(10) "PHP Basics" +} +]]> + + + + + + SimpleXMLIterator::valid - Check whether SimpleXML contains more entries + Check whether the current element is valid &reftitle.description; @@ -11,9 +11,9 @@ boolSimpleXMLIterator::valid - - &warn.undocumented.func; - + + This method checks if the current element is valid after calls to rewind() or next(). + @@ -24,7 +24,29 @@ &reftitle.returnvalues; - &true; if contains more SimpleXML entries, otherwise &false; + Returns &true; if the current element is valid, otherwise &false; + + + + + &reftitle.examples; + + + Check whether the current element is valid + +SQL Basics'); + +$xmlIterator->rewind(); // rewind to the first element +echo var_dump($xmlIterator->valid()); // bool(true) + +$xmlIterator->next(); // advance to the next element +echo var_dump($xmlIterator->valid()); // bool(false) because there is only one element +?> +]]> + +