title: Java xml parser loop
body: <p>I have this xml file:</p>
  
  <pre><code>&lt;root&gt;
      &lt;application&gt;
          &lt;interface /&gt;
          &lt;interface /&gt;
      &lt;/application&gt;
  
      &lt;datatransmit&gt;
          &lt;interface /&gt;
      &lt;/datatransmit&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>What I am trying to do is first do a loop through the interfaces within the <code>&lt;application&gt;</code> tags and then another loop through the interfaces withing the <code>&lt;datatransmit&gt;</code> tags.</p>
  
  <p>I tried this with this Java code:</p>
  
  <pre><code>NodeList application = doc.getElementsByTagName("application");
  for (int i = 0; i &lt; application.getLength(); i++) {
      NodeList interfaces = doc.getElementsByTagName("interface");
      for (int j = 0; j &lt; interfaces.getLength(); j++) {
          do some stuff...
      }
  }
  </code></pre>
  
  <p>I noticed that with this loop, it goes through a loop of all the interface elements. Not just the interfaces withing the <code>application</code> tags but also the interfaces within <code>datatransmit</code>.
  What would be a way to solve this?</p>