Chilkat parsing XML - Looping problem

532 views Asked by At

I'm using the Chilkat to parse the XML response from an external API. This works perfectly when XML is formed as follows:

<response>
<field1>data1a</field1>
<field2>data2a</field2>
<field3>data2a</field2>
</response>
<response>
<field1>data1b</field1>
<field2>data2b</field2>
<field3>data2b</field2>
</response>

using .NextSibling() to loop through nodes; however, when XML is formed as follows:

<response>
<data field1="data1a" field2="data2a" field3="data3a"/>
<data field1="data1b" field2="data2b" field3="data3b"/>
</response>

Only the first node is captured (using .ChilkatPath to extract the attributes) and .NextSibling() has no effect.

What should I be using to loop though these nodes?

Thanks for your help

1

There are 1 answers

0
Shai Mishali On

I'm just throwing a shot in the dark here, but is there a chance you're parsing the "response" field instead of the "data" field ?

On the first example response has a sibling (2 tags), on the second example there's only 1 "response" tag, so maybe that explains why there's no siblings to it.

Shai.