title: JAVA XML - How do I get specific elements in an XML Node?
body: <p>This is an academic assignment and we are given an extremely large XML file with hundreds of entries like these. For each item we are supposed to list the Manager's ID, the Person's ID of the last person to add an item to the list, and the current number of items. I have read and reread the Oracle DOM API and various Node APIs. We are using JAVA and I cannot for the life of me figure out how to search various 'fields' of each <code>item_list</code> node. Below is an example of the data we are given.</p>
  
  <pre><code>&lt;item_list id="item_list01"&gt;
     &lt;numitems_intial&gt;5&lt;/numitems_initial&gt;
     &lt;item&gt;
       &lt;date_added&gt;1/1/2014&lt;/date_added&gt;
       &lt;added_by person="person01" /&gt;
     &lt;/item&gt;
     &lt;item&gt;
        &lt;date_added&gt;1/6/2014&lt;/date_added&gt;
        &lt;added_by person="person05" /&gt;
      &lt;/item&gt;
      &lt;numitems_current&gt;7&lt;/numitems_current&gt;
      &lt;manager person="person48" /&gt;
  &lt;/item_list&gt;
  &lt;item_list id="item_list02"&gt;
     &lt;numitems_intial&gt;5&lt;/numitems_initial&gt;
     &lt;item&gt;
       &lt;date_added&gt;1/15/2014&lt;/date_added&gt;
       &lt;added_by person="person05" /&gt;
     &lt;/item&gt;
     &lt;item&gt;
       &lt;date_added&gt;1/1/2014&lt;/date_added&gt;
       &lt;added_by person="person09" /&gt;
     &lt;/item&gt;
         &lt;item&gt;
           &lt;date_added&gt;1/9/2014&lt;/date_added&gt;
           &lt;added_by person="person45" /&gt;
         &lt;/item&gt;
          &lt;numitems_current&gt;7&lt;/numitems_current&gt;
          &lt;manager person="person38" /&gt;
      &lt;/item_list&gt;
  </code></pre>
  
  <p>I've tried doing something similar to:</p>
  
  <pre><code>NodeList nodes = queryDoc.getElementsByTagName("item_list");
  
  for(int i = 0; i &lt; nodes.getLength(); i++) {
  
      Node node = nodes.item(i);
  
      if(node != null) {
  
         System.out.println(node.manager);
  
      }
  
  }
  </code></pre>
  
  <p>And messing around with this code for a while, but I would like to know how to retrieve data from various fields in each node.</p>