Skip to content

Commit c4f9956

Browse files
committed
Move iterator methods of SimpleXMLIterator to SimpleXMLElement
1 parent a2097ad commit c4f9956

File tree

9 files changed

+206
-167
lines changed

9 files changed

+206
-167
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- $Revision$ -->
3+
<refentry xml:id="simplexmlelement.current" xmlns="http://docbook.org/ns/docbook">
4+
<refnamediv>
5+
<refname>SimpleXMLElement::current</refname>
6+
<refpurpose>Returns the current element</refpurpose>
7+
</refnamediv>
8+
<refsect1 role="description">
9+
&reftitle.description;
10+
<methodsynopsis role="SimpleXMLElement">
11+
<modifier>public</modifier> <type>SimpleXMLElement</type><methodname>SimpleXMLElement::current</methodname>
12+
<void/>
13+
</methodsynopsis>
14+
<para>
15+
This method returns the current element as a <classname>SimpleXMLElement</classname> object.
16+
</para>
17+
</refsect1>
18+
19+
<refsect1 role="parameters">
20+
&reftitle.parameters;
21+
&no.function.parameters;
22+
</refsect1>
23+
24+
<refsect1 role="returnvalues">
25+
&reftitle.returnvalues;
26+
<para>
27+
Returns the current element as a <classname>SimpleXMLElement</classname> object, or an <classname>Error</classname>
28+
is thrown on failure.
29+
</para>
30+
</refsect1>
31+
32+
33+
<refsect1 role="changelog">
34+
&reftitle.changelog;
35+
<informaltable>
36+
<tgroup cols="2">
37+
<thead>
38+
<row>
39+
<entry>&Version;</entry>
40+
<entry>&Description;</entry>
41+
</row>
42+
</thead>
43+
<tbody>
44+
<row>
45+
<entry>8.1.0</entry>
46+
<entry>
47+
An <classname>Error</classname> is now thrown if
48+
<methodname>SimpleXMLElement::current</methodname> is called on an
49+
invalid iterator. Previously, &null; was returned.
50+
</entry>
51+
</row>
52+
</tbody>
53+
</tgroup>
54+
</informaltable>
55+
</refsect1>
56+
57+
<refsect1 role="examples">
58+
&reftitle.examples;
59+
<para>
60+
<example>
61+
<title>Return the current element</title>
62+
<programlisting role="php">
63+
<![CDATA[
64+
<?php
65+
$xmlElement = new SimpleXMLElement('<books><book>PHP basics</book><book>XML basics</book></books>');
66+
var_dump($xmlIElement->current());
67+
68+
$xmlElement->rewind(); // rewind to first element
69+
var_dump($xmlElement->current());
70+
?>
71+
]]>
72+
</programlisting>
73+
&example.outputs;
74+
<screen>
75+
<![CDATA[
76+
NULL
77+
object(SimpleXMLElement)#2 (1) {
78+
[0]=>
79+
string(10) "PHP basics"
80+
}
81+
]]>
82+
</screen>
83+
</example>
84+
</para>
85+
</refsect1>
86+
87+
<refsect1 role="seealso">
88+
&reftitle.seealso;
89+
<para>
90+
<simplelist>
91+
<member><methodname>SimpleXMLElement::key</methodname></member>
92+
<member><methodname>SimpleXMLElement::next</methodname></member>
93+
<member><methodname>SimpleXMLElement::rewind</methodname></member>
94+
<member><methodname>SimpleXMLElement::valid</methodname></member>
95+
<member><classname>SimpleXMLElement</classname></member>
96+
</simplelist>
97+
</para>
98+
</refsect1>
99+
100+
</refentry>
101+
<!-- Keep this comment at the end of the file
102+
Local variables:
103+
mode: sgml
104+
sgml-omittag:t
105+
sgml-shorttag:t
106+
sgml-minimize-attributes:nil
107+
sgml-always-quote-attributes:t
108+
sgml-indent-step:1
109+
sgml-indent-data:t
110+
indent-tabs-mode:nil
111+
sgml-parent-document:nil
112+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
113+
sgml-exposed-tags:nil
114+
sgml-local-catalogs:nil
115+
sgml-local-ecat-files:nil
116+
End:
117+
vim600: syn=xml fen fdm=syntax fdl=2 si
118+
vim: et tw=78 syn=sgml
119+
vi: ts=1 sw=1
120+
-->

reference/simplexml/simplexmliterator/getchildren.xml renamed to reference/simplexml/simplexmlelement/getchildren.xml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<refentry xml:id="simplexmliterator.getchildren" xmlns="http://docbook.org/ns/docbook">
3+
<refentry xml:id="simplexmlelement.getchildren" xmlns="http://docbook.org/ns/docbook">
44
<refnamediv>
5-
<refname>SimpleXMLIterator::getChildren</refname>
5+
<refname>SimpleXMLElement::getChildren</refname>
66
<refpurpose>Returns the sub-elements of the current element</refpurpose>
77
</refnamediv>
88
<refsect1 role="description">
99
&reftitle.description;
10-
<methodsynopsis>
11-
<modifier>public</modifier> <type>SimpleXMLIterator</type><methodname>SimpleXMLIterator::getChildren</methodname>
10+
<methodsynopsis role="SimpleXMLElement">
11+
<modifier>public</modifier> <type class="union"><type>SimpleXMLElement</type><type>null</type></type><methodname>SimpleXMLElement::getChildren</methodname>
1212
<void/>
1313
</methodsynopsis>
1414
<para>
15-
This method returns a <classname>SimpleXMLIterator</classname> object
16-
containing sub-elements of the current <classname>SimpleXMLIterator</classname>
15+
This method returns a <classname>SimpleXMLElement</classname> object
16+
containing sub-elements of the current <classname>SimpleXMLElement</classname>
1717
element.
1818
</para>
1919
</refsect1>
@@ -26,7 +26,7 @@
2626
<refsect1 role="returnvalues">
2727
&reftitle.returnvalues;
2828
<para>
29-
Returns a <classname>SimpleXMLIterator</classname> object containing
29+
Returns a <classname>SimpleXMLElement</classname> object containing
3030
the sub-elements of the current element.
3131
</para>
3232
</refsect1>
@@ -49,9 +49,9 @@ $xml = <<<XML
4949
</books>
5050
XML;
5151
52-
$xmlIterator = new SimpleXMLIterator($xml);
53-
for( $xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next() ) {
54-
foreach($xmlIterator->getChildren() as $name => $data) {
52+
$xmlElement = new SimpleXMLElement($xml);
53+
for ($xmlElement->rewind(); $xmlElement->valid(); $xmlElement->next()) {
54+
foreach($xmlElement->getChildren() as $name => $data) {
5555
echo "The $name is '$data' from the class " . get_class($data) . "\n";
5656
}
5757
}
@@ -61,16 +61,15 @@ for( $xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next() ) {
6161
&example.outputs;
6262
<screen>
6363
<![CDATA[
64-
The title is 'PHP Basics' from the class SimpleXMLIterator
65-
The author is 'Jim Smith' from the class SimpleXMLIterator
64+
The title is 'PHP Basics' from the class SimpleXMLElement
65+
The author is 'Jim Smith' from the class SimpleXMLElement
6666
]]>
6767
</screen>
6868
</example>
6969
</para>
7070
</refsect1>
7171

7272
</refentry>
73-
7473
<!-- Keep this comment at the end of the file
7574
Local variables:
7675
mode: sgml

reference/simplexml/simplexmliterator/haschildren.xml renamed to reference/simplexml/simplexmlelement/haschildren.xml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<refentry xml:id="simplexmliterator.haschildren" xmlns="http://docbook.org/ns/docbook">
3+
<refentry xml:id="simplexmlelement.haschildren" xmlns="http://docbook.org/ns/docbook">
44
<refnamediv>
5-
<refname>SimpleXMLIterator::hasChildren</refname>
5+
<refname>SimpleXMLElement::hasChildren</refname>
66
<refpurpose>Checks whether the current element has sub elements</refpurpose>
77
</refnamediv>
88
<refsect1 role="description">
99
&reftitle.description;
10-
<methodsynopsis>
11-
<modifier>public</modifier> <type>bool</type><methodname>SimpleXMLIterator::hasChildren</methodname>
10+
<methodsynopsis role="SimpleXMLElement">
11+
<modifier>public</modifier> <type>bool</type><methodname>SimpleXMLElement::hasChildren</methodname>
1212
<void/>
1313
</methodsynopsis>
1414
<para>
15-
This method checks whether the current <classname>SimpleXMLIterator</classname> element has sub-elements.
15+
This method checks whether the current <classname>SimpleXMLElement</classname> element has sub-elements.
1616
</para>
1717
</refsect1>
1818

@@ -46,10 +46,10 @@ $xml = <<<XML
4646
</books>
4747
XML;
4848
49-
$xmlIterator = new SimpleXMLIterator( $xml );
50-
for( $xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next() ) {
51-
if($xmlIterator->hasChildren()) {
52-
var_dump($xmlIterator->current());
49+
$xmlElement = new SimpleXMLElement($xml);
50+
for ($xmlElement->rewind(); $xmlElement->valid(); $xmlElement->next()) {
51+
if ($xmlElement->hasChildren()) {
52+
var_dump($xmlElement->current());
5353
}
5454
}
5555
?>
@@ -58,7 +58,7 @@ for( $xmlIterator->rewind(); $xmlIterator->valid(); $xmlIterator->next() ) {
5858
&example.outputs;
5959
<screen>
6060
<![CDATA[
61-
object(SimpleXMLIterator)#2 (2) {
61+
object(SimpleXMLElement)#2 (2) {
6262
["title"]=>
6363
string(10) "PHP Basics"
6464
["author"]=>
@@ -71,7 +71,6 @@ object(SimpleXMLIterator)#2 (2) {
7171
</refsect1>
7272

7373
</refentry>
74-
7574
<!-- Keep this comment at the end of the file
7675
Local variables:
7776
mode: sgml

reference/simplexml/simplexmliterator/key.xml renamed to reference/simplexml/simplexmlelement/key.xml

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<refentry xml:id="simplexmliterator.key" xmlns="http://docbook.org/ns/docbook">
3+
<refentry xml:id="simplexmlelement.key" xmlns="http://docbook.org/ns/docbook">
44
<refnamediv>
5-
<refname>SimpleXMLIterator::key</refname>
5+
<refname>SimpleXMLElement::key</refname>
66
<refpurpose>Return current key</refpurpose>
77
</refnamediv>
88
<refsect1 role="description">
99
&reftitle.description;
10-
<methodsynopsis>
11-
<modifier>public</modifier> <type>mixed</type><methodname>SimpleXMLIterator::key</methodname>
10+
<methodsynopsis role="SimpleXMLElement">
11+
<modifier>public</modifier> <type>string</type><methodname>SimpleXMLElement::key</methodname>
1212
<void/>
1313
</methodsynopsis>
1414
<para>
@@ -25,10 +25,35 @@
2525
<refsect1 role="returnvalues">
2626
&reftitle.returnvalues;
2727
<para>
28-
Returns the XML tag name of the element referenced by the current <classname>SimpleXMLIterator</classname> object or &false;
28+
Returns the XML tag name of the element referenced by the current <classname>SimpleXMLElement</classname> object or
29+
an <classname>Error</classname> is thrown on failure.
2930
</para>
3031
</refsect1>
3132

33+
<refsect1 role="changelog">
34+
&reftitle.changelog;
35+
<informaltable>
36+
<tgroup cols="2">
37+
<thead>
38+
<row>
39+
<entry>&Version;</entry>
40+
<entry>&Description;</entry>
41+
</row>
42+
</thead>
43+
<tbody>
44+
<row>
45+
<entry>8.1.0</entry>
46+
<entry>
47+
An <classname>Error</classname> is now thrown if
48+
<methodname>SimpleXMLElement::key</methodname> is called on an
49+
invalid iterator. Previously, &false; was returned.
50+
</entry>
51+
</row>
52+
</tbody>
53+
</tgroup>
54+
</informaltable>
55+
</refsect1>
56+
3257
<refsect1 role="examples">
3358
&reftitle.examples;
3459
<para>
@@ -37,11 +62,11 @@
3762
<programlisting role="php">
3863
<![CDATA[
3964
<?php
40-
$xmlIterator = new SimpleXMLIterator('<books><book>PHP basics</book><book>XML basics</book></books>');
65+
$xmlElement = new SimpleXMLElement('<books><book>PHP basics</book><book>XML basics</book></books>');
4166
42-
echo var_dump($xmlIterator->key());
43-
$xmlIterator->rewind(); // rewind to the first element
44-
echo var_dump($xmlIterator->key());
67+
echo var_dump($xmlElement->key());
68+
$xmlElement->rewind(); // rewind to the first element
69+
echo var_dump($xmlElement->key());
4570
4671
?>
4772
]]>
@@ -58,7 +83,6 @@ string(4) "book"
5883
</refsect1>
5984

6085
</refentry>
61-
6286
<!-- Keep this comment at the end of the file
6387
Local variables:
6488
mode: sgml

reference/simplexml/simplexmliterator/next.xml renamed to reference/simplexml/simplexmlelement/next.xml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<refentry xml:id="simplexmliterator.next" xmlns="http://docbook.org/ns/docbook">
3+
<refentry xml:id="simplexmlelement.next" xmlns="http://docbook.org/ns/docbook">
44
<refnamediv>
5-
<refname>SimpleXMLIterator::next</refname>
5+
<refname>SimpleXMLElement::next</refname>
66
<refpurpose>Move to next element</refpurpose>
77
</refnamediv>
88
<refsect1 role="description">
99
&reftitle.description;
10-
<methodsynopsis>
11-
<modifier>public</modifier> <type>void</type><methodname>SimpleXMLIterator::next</methodname>
10+
<methodsynopsis role="SimpleXMLElement">
11+
<modifier>public</modifier> <type>void</type><methodname>SimpleXMLElement::next</methodname>
1212
<void/>
1313
</methodsynopsis>
1414
<para>
15-
This method moves the <classname>SimpleXMLIterator</classname> to the next element.
15+
This method moves the <classname>SimpleXMLElement</classname> to the next element.
1616
</para>
1717
</refsect1>
1818

@@ -36,18 +36,18 @@
3636
<programlisting role="php">
3737
<![CDATA[
3838
<?php
39-
$xmlIterator = new SimpleXMLIterator('<books><book>PHP Basics</book><book>XML basics</book></books>');
40-
$xmlIterator->rewind(); // rewind to the first element
41-
$xmlIterator->next();
39+
$xmlElement = new SimpleXMLElement('<books><book>PHP Basics</book><book>XML basics</book></books>');
40+
$xmlElement->rewind(); // rewind to the first element
41+
$xmlElement->next();
4242
43-
var_dump($xmlIterator->current());
43+
var_dump($xmlElement->current());
4444
?>
4545
]]>
4646
</programlisting>
4747
&example.outputs;
4848
<screen>
4949
<![CDATA[
50-
object(SimpleXMLIterator)#2 (1) {
50+
object(SimpleXMLElement)#2 (1) {
5151
[0]=>
5252
string(10) "XML basics"
5353
}
@@ -58,7 +58,6 @@ object(SimpleXMLIterator)#2 (1) {
5858
</refsect1>
5959

6060
</refentry>
61-
6261
<!-- Keep this comment at the end of the file
6362
Local variables:
6463
mode: sgml

0 commit comments

Comments
 (0)