Re: [xml] inconsistent behavior by "xmlChildElementCount()"
- From: JerryWRice <JerryWRice fabnexus com>
- To: xml gnome org
- Subject: Re: [xml] inconsistent behavior by "xmlChildElementCount()"
- Date: Sat, 28 Aug 2010 11:54:45 -0700
Hello,
This is my first posting, but I've been using 'libxml2' on Linux
for about a year. During some of my recent testing, I've encountered
something that appears to be a problem. While parsing what should be a
valid XML document from a 'c' program (not "c++), I've found that the
"xmlChildElementCount()" function returns an erroneous child element
count for certain documents. Below is one such document (I've added
line numbers on the left column - these are not a part of the XML document):
1 <?xml version="1.0"?> <methodCall>
2 <methodName>filtermap.add</methodName>
3 <params>
4 <param>
5 <value><string>fname</string></value>
6 </param>
7 <param name="input">
8 <value>
9 <array>
10 <data>
11 <value><string>portid1</string></value>
12 <value><string>portid2</string></value>
13 <value><string>portid3</string></value>
14 </data>
15 </array>
16 </value>
17 </param>
18 <param name="output">
19 <value>
20 <array>
21 <data>
22 <value><string>monitor_portid1</string></value>
23 <value><string>monitor_portid2</string></value>
24 <value><string>monitor_portid3</string></value>
25 </data>
26 </array>
27 </value>
28 </param>
29 <param>
30 <value>
31 <array>
32 <data>
33 <value><int>10</int></value>
34 <value><string>arg1</string></value>
35 <value><i4>100</i4></value>
36 <value>
37 <array>
38 <data>
39 <value><int>1000</int></value>
40 <value><string>hello</string></value>
41 <value><string>goodbye</string></value>
42 </data>
43 </array>
44 </value>
45 </data>
46 </array>
47 </value>
48 </param>
49 </params>
50 </methodCall>
My program places this XML document into a zero-terminated char text
buffer and creates a reader for it using "xmlReaderForDoc()". Then I
perform a series of "xmlTextReaderRead()" calls to advance my current
node to element "<params>" on line 3. I've confirmed I'm at the opening
"<params>" node by using function "xmlTextReadName()" to verify. While
positioned at node "<params>", I call function "xmlChildElementCount()"
and expect to get a child element count of "4" (there are four "<param>"
sub-element nodes), but instead receive return count value of "3". I've
experimented by changing the number of "<param>" nodes, but get various
erroneous counts (always less than the actual count) as long as I have
deeply nested "<param>" element sub-nodes. If I replace the "<array>"
(deeply nested) nodes with simpler less deeply nested ones, the child
node count seems to be returned properly.
This is a real problem for my program.
Any ideas what what might be happening?
Thanks in advance.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]