title: How to know what child is belonging to their parent?
body: <p>I have a XML-file with over 12k tags.
  All the tags have a tagId, like:</p>
  
  <pre><code>&lt;first_tag&gt;                   tagId = 1
     &lt;second_tag_first_child&gt;   tagId = 2
  </code></pre>
  
  <p>So on, so forth.</p>
  
  <p>In addition to tagId they all need to have an parentId, so the child know what parent they belong to.</p>
  
  <pre><code>&lt;root_tag&gt;                               parentId = 0 | tagId = 1
    &lt;first_tag&gt;                            parentId = 1 | tagId = 2
       &lt;second_tag_first_child&gt;            parentId = 2 | tagId = 3
       &lt;third_tag_second_child&gt;            parentId = 2 | tagId = 4
          &lt;fourth_tag_first_grandchild&gt;    parentId = 4 | tagId = 5
    &lt;fifth_tag&gt;                            parentId = 1 | tagId = 6
  </code></pre>
  
  <p>Does anyone know how to make the logic so i can get the parentId?
  What I need is a <code>System.out.println(tag + parentId + tagId + "\n")</code></p>