Your XML structure does not match with what you're code "expects". Your code seems to expect a hierarchical XML input, where each Parser
holds data
nodes and each data
holds first
nodes:
<Parser id="ADPParser2">
<data type="Sales">
<first record="DEAL-NO" />
</data>
<data type="Service">
<first record="RO" />
</data>
<data type="Email">
<first record="CONTROL" />
</data>
</Parser>
However, your XML input is flat: the data
and first
nodes are direct children of a Parser
. Your indentation seems to suggest otherwise (which probably caused this confusion), but it really is equivalent to:
<Parser id="ADPParser2">
<data type="Sales" />
<first record="DEAL-NO" />
<data type="Service" />
<first record="RO" />
<data type="Email" />
<first record="CONTROL" />
</Parser>
I can see two solutions:
- Fix the structure of your XML input to be hierarchical, like your code expects it.
- Fix your code to work with the "flat" style (although I don't think that's what you want).