Reputation: 1957
I'm trying to parse this XML string:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<response type="success">
<lots>
<lot>32342</lot>
<lot>52644</lot>
</lots>
</response>
When I get the root node, which is "response", I use the method getChildNodes() which returns a NodeList of length 3. However what I'm confused about is the order the NodeList gets created in. I used some print statements to show whats in the list
Item length: 3
Item (0): [#text:
]
Item (1): [lots: null]
Item (2): [#text:
]
So the text node is first which is two levels below the root, then the next child of the root, and then the next text node.
Is there a particular order and/or reason the list is ordered in this way?
Upvotes: 0
Views: 837
Reputation: 1957
Actually I found the problem, I was using '\n' characters which was causing extra text nodes being parsed
Upvotes: 0
Reputation: 8534
You are seeing the whitespace text surrounding the childnode "lots"
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<response type="success">
{txt1}<lots>
<lot>32342</lot>
<lot>52644</lot>
</lots>{txt2}
</response>
Upvotes: 3