title: Get child Node of another Node, given node name
body: <p>I have an XML like this:</p>
  
  <pre><code>&lt;documentslist&gt;
    &lt;document&gt;
      &lt;docnumber&gt;1&lt;/docnumber&gt;
      &lt;docname&gt;Declaration of Human Rights&lt;/docname&gt;
      &lt;aoo&gt;lib&lt;/aoo&gt;
    &lt;/document&gt;
    &lt;document&gt;
      &lt;docnumber&gt;2&lt;/docnumber&gt;
      &lt;docname&gt;Fair trade&lt;/docname&gt;
      &lt;aoo&gt;lib&lt;/aoo&gt;
    &lt;/document&gt;
    &lt;document&gt;
      &lt;docnumber&gt;3&lt;/docnumber&gt;
      &lt;docname&gt;The wars for water&lt;/docname&gt;
      &lt;aoo&gt;lib&lt;/aoo&gt;
    &lt;/document&gt;
    &lt;!-- etc. --&gt;
  &lt;/documentslist&gt;
  </code></pre>
  
  <p>I have this code:</p>
  
  <pre><code>//XML parsing
  Document docsDoc = null;
  try {
      DocumentBuilder db = dbf.newDocumentBuilder();
      docsDoc = db.parse(new InputSource(new StringReader(xmlWithDocs)));
  }
  catch(ParserConfigurationException e) {e.printStackTrace();}
  catch(SAXException e) {e.printStackTrace();}
  catch(IOException e) {e.printStackTrace();}
  //retrieve document elements
  NodeList docs = docsDoc.getElementsByTagName("document");
  
  if (docs.getLength() &gt; 0){
      //print a row for each document
      for (int i=0; i&lt;docs.getLength(); i++){
          //get current document
          Node doc = docs.item(i);
          //print a cell for some document children
          for (int j=0; j&lt;columns.length; j++){
              Node cell;
              //print docname
              cell = doc.getElementsByTagName("docname").item(0); //doesn't work
              System.out.print(cell.getTextContent() + "\t");
              //print aoo
              cell = doc.getElementsByTagName("aoo").item(0); //doesn't work
              System.out.print(cell.getTextContent() + "\t");
          }
          System.out.println();
      }
  }
  </code></pre>
  
  <p>But, as you know <strong><code>Node</code> hasn't got <code>getElementsByTagName</code> method</strong>... Only <code>Document</code> has it. But I can't do <code>docsDoc.getElementsByTagName("aoo")</code>, because it will return me all <code>&lt;aoo&gt;</code> nodes, not only the one existing in the <code>&lt;document&gt;</code> node I'm inspecting.</p>
  
  <p>How could I do it? Thanks!</p>