title: How to get child nodes with ELEMENT_NODE type only
body: <p>I'm parsing a xml document using java DOM and I need to get every single node for doing something.</p>
  
  <p>I have this code:</p>
  
  <pre><code>public void analyze_file(Node node){
          if(node.getNodeType() != Node.DOCUMENT_NODE){
              //do something
          }
          NodeList list = node.getChildNodes();
          for(int i=0; i&lt;list.getLength(); i++){
              if(list.item(i).getNodeType() == Node.ELEMENT_NODE){
                  analyze_file(list.item(i));
              }
          }
  }
  </code></pre>
  
  <p>The problem is that, my xml file is very large <em>( > 30000 lines)</em>, and the code above needs too much time for checking whether a node is of <code>ELEMENT_NODE</code> type or not. I see that if the program stopped after it reached the last <code>ELEMENT_NODE</code> node, the execution time would be very small.</p>
  
  <p>Is there any way to get all child nodes whose type is <code>ELEMENT_NODE</code> only?</p>
  
  <p>For example: <code>NodeList list = node.getElementChildNodes();</code></p>
  
  <p>Thanks for any help!</p>