title: getChildNodes giving unexpected result
body: <p>My XML looks like this- </p>
  
  <pre><code>&lt;collected_objects&gt;
          &lt;object flag="complete" id="objId" version="1"&gt;
            &lt;variable_value variable_id="varId"&gt;ValueGoesHere&lt;/variable_value&gt;
            &lt;reference item_ref="2"/&gt;
          &lt;/object&gt;
          &lt;object comment="objComment" flag="complete" id="objId" version="1"&gt;
            &lt;reference item_ref="1"/&gt;
          &lt;/object&gt;
  &lt;/collected_objects&gt;
  </code></pre>
  
  <p>I am processing it using below code- </p>
  
  <pre><code>Document dom = parser.getDocument();
      NodeList collected_objects = dom.getElementsByTagName("object");
      System.out.println("Number of collected objects are " + collected_objects.getLength());
  
          for (int i = 0; i &lt; collected_objects.getLength(); i++) {
  
              Node aNode = collected_objects.item(i);
              //get children of "objects"         
              NodeList refNodes = aNode.getChildNodes();
  
              System.out.println("# of chidren are " + refNodes.getLength());
  
              //print attributes of "objects"
  
              NamedNodeMap attributes = aNode.getAttributes();
              for (int a = 0; a &lt; attributes.getLength(); a++) {
               Node theAttribute = attributes.item(a);
               System.out.println(theAttribute.getNodeName() + "=" + theAttribute.getNodeValue());
  
          }
  
  }
  </code></pre>
  
  <p>it outputs as- </p>
  
  <pre><code>Number of collected objects are 2
  # of chidren are 5
  flag=complete
  id=objId
  version=1
  # of chidren are 3
  comment=objComment
  flag=complete
  id=objId
  version=1
  </code></pre>
  
  <p>My question is why "# of chidren are" are 5 and 3 respectively? Shouldn't I be expecting 2 and 1 respectively ?
  because first object has "<code>variable_value</code>" and "<code>reference</code>" and second object has only "<code>reference</code>"</p>
  
  <p>Essentially, my intent is to process children of "objects".</p>