Identifying Parent and child Tag in XML

  • Thread starter Thread starter Umeshnath
  • Start date Start date
U

Umeshnath

Hi,
I have a XML file which contains some Container and item information.
Both the tag identying by the same tag (Container).
But the outer is parent one and all other are child to that parent.

In this eg total 2 parent an 4 items are there.
.By programitilly how can i Distingush.
eg :
<Container>
<ContainerHandle>urn:epc:id:gid:49603356.41P.000001</ContainerHandle>
<Container>
<ContainerHandle>urn:epc:id:gid:49603356.41C.000001</ContainerHandle>
</Container
<Container> <ContainerHandle>urn:epc:id:gid:49603356.41C.000002</ContainerHandle>
</Container>
</Container>

<Container>
<ContainerHandle>urn:epc:id:gid:49603356.51P.000001</ContainerHandle>
<Container>
<ContainerHandle>urn:epc:id:gid:49603356.51C.000001</ContainerHandle>
</Container
<Container> <ContainerHandle>urn:epc:id:gid:49603356.51C.000002</ContainerHandle>
</Container>
</Container>

Thanks in advance
Umeshnath
 
I think XPath can help you here.

Another (less optimized) way might be to loop through all nodes in an
recursive fassion, if parent-child will continue deep down to an unknown
level, if level known u can set the nesting likewise.

Thanks,
Harshal
 
Back
Top