[XML Records] XML Element at multiple levels

[XML Records] XML Element at multiple levels

Forge Component
Published on 2016-06-15 by Ricardo Silva
25 votes
Published on 2016-06-15 by Ricardo Silva
If you have an XML element at multiple levels in your document then you may not get the results you're expecting.


When you reach the /ParentElement/Name element you might just find that the structure ParentElement.Name ends up containing "ChildName".

In J2EE the fix is to iterate over the collection of nodes and make sure you pick the one at the correct level.

In the Deserialize method, after getting the NodeList, don't just take item(0):

NodeList nodes = getElements(nameSpace, tagName, elem);

Node node = null;

for(int ix = 0; ix<nodes.getLength(); ix++){

  // do not pick from descendants.


        node = nodes.item(ix);





Hello Stuart,

I will look into this matter, but it might be quicker for me to validate what's happening if you provide a small eSpace which illustrates the problem you're having.

Can you please provide one for me ?

Best regards,
Ricardo Silva
Test eSpace attached.

Try moving the /Parent/Name element before and after the /Parent/Children element to see the difference in the loaded data.


Hello Stuart,

Thank you very much for catching this problem and for digging into it.

I have now published version 1.5.8 of XML Records which fixes this issue.

Best regards,
Ricardo Silva