Identifying Parent and child Tag in XML

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
 
H

Harshal

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top