XML : How to know what child is belonging to their parent?

I have a XML-file with over 12k tags. All the tags have a tagId, like:

  <first_tag>                   tagId = 1     <second_tag_first_child>   tagId = 2    

So on, so forth.

In addition to tagId they all need to have an parentId, so the child know what parent they belong to.

  <root_tag>                               parentId = 0 | tagId = 1    <first_tag>                            parentId = 1 | tagId = 2       <second_tag_first_child>            parentId = 2 | tagId = 3       <third_tag_second_child>            parentId = 2 | tagId = 4          <fourth_tag_first_grandchild>    parentId = 4 | tagId = 5    <fifth_tag>                            parentId = 1 | tagId = 6    

Does anyone know how to make the logic so i can get the parentId?

No comments:

Post a Comment