Identifying Parent and child Tag in XML
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
Re: Identifying Parent and child Tag in XML
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
"Umeshnath" <Umeshnath [at] discussions.microsoft.com> wrote in message
news:588D7EEB-054C-4DCC-ABB2-963C7F1EA34A [at] microsoft.com...
> 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