reference/xml/functions/xml-parse-into-struct.xml
4138897b1260ec3601c799cf4418f30ef8b29bce
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.xml-parse-into-struct">
3
+
<refentry xml:id="function.xml-parse-into-struct" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>xml_parse_into_struct</refname>
6
6
<refpurpose>Parse XML data into an array structure</refpurpose>
...
...
@@ -10,10 +10,10 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>int</type><methodname>xml_parse_into_struct</methodname>
13
-
<methodparam><type>resource</type><parameter>parser</parameter></methodparam>
13
+
<methodparam><type>XMLParser</type><parameter>parser</parameter></methodparam>
14
14
<methodparam><type>string</type><parameter>data</parameter></methodparam>
15
15
<methodparam><type>array</type><parameter role="reference">values</parameter></methodparam>
16
-
<methodparam choice="opt"><type>array</type><parameter role="reference">index</parameter></methodparam>
16
+
<methodparam choice="opt"><type>array</type><parameter role="reference">index</parameter><initializer>&null;</initializer></methodparam>
17
17
</methodsynopsis>
18
18
<para>
19
19
This function parses an XML string into 2 parallel array structures, one
...
...
@@ -72,6 +72,23 @@
72
72
</para>
73
73
</refsect1>
74
74

75
+
<refsect1 role="changelog">
76
+
&reftitle.changelog;
77
+
<informaltable>
78
+
<tgroup cols="2">
79
+
<thead>
80
+
<row>
81
+
<entry>&Version;</entry>
82
+
<entry>&Description;</entry>
83
+
</row>
84
+
</thead>
85
+
<tbody>
86
+
&xml.changelog.parser-param;
87
+
</tbody>
88
+
</tgroup>
89
+
</informaltable>
90
+
</refsect1>
91
+

75
92
<refsect1 role="examples">
76
93
&reftitle.examples;
77
94
<para>
...
...
@@ -151,7 +168,7 @@ Array
151
168
Event-driven parsing (based on the expat library) can get
152
169
complicated when you have an XML document that is complex.
153
170
This function does not produce a DOM style object, but it
154
-
generates structures amenable of being transversed in a tree
171
+
generates structures amenable of being traversed in a tree
155
172
fashion. Thus, we can create objects representing the data
156
173
in the XML file easily. Let's consider the following XML file
157
174
representing a small database of aminoacids information:
...
...
@@ -197,7 +214,7 @@ class AminoAcid {
197
214
var $code; // one letter code
198
215
var $type; // hydrophobic, charged or neutral
199
216
200
-
function AminoAcid ($aa)
217
+
function __construct ($aa)
201
218
{
202
219
foreach ($aa as $k=>$v)
203
220
$this->$k = $aa[$k];
...
...
@@ -207,7 +224,7 @@ class AminoAcid {
207
224
function readDatabase($filename)
208
225
{
209
226
// read the XML database of aminoacids
210
-
$data = implode("", file($filename));
227
+
$data = file_get_contents($filename);
211
228
$parser = xml_parser_create();
212
229
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
213
230
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
...
...
@@ -282,7 +299,6 @@ Array
282
299
</refsect1>
283
300

284
301
</refentry>
285
-

286
302
<!-- Keep this comment at the end of the file
287
303
Local variables:
288
304
mode: sgml
289
305