title: How to extract XML nodes ignoring the descendent elements in Java
body: <p>I have structure in XML like this:</p>
  
  <pre><code>&lt;allcontents&gt;
      &lt;notinteresting1&gt;
         nothing relevant
      &lt;/notinteresting1&gt;
      &lt;notinteresting2&gt;
         nothing relevant either
      &lt;/notinteresing2&gt;
      i want just this content
  &lt;/allcontents&gt; 
  </code></pre>
  
  <p>I would like to read the contents that are inside "allcontents" but outside any other element.</p>
  
  <p>I tried to read the node with a code like this in Java</p>
  
  <pre><code>String allcontents =  eElement.getElementsByTagName(allcontents).item(0).getTextContent();
  </code></pre>
  
  <p>But this will return all the contents of the node, which is not what I am interested in.</p>