title: Node.getTextContent() is there a way to get text content of the current node, not the descendant's text
body: <p>Node.getTextContent() returns the text content of the current node and its descendants.</p>
  
  <p>is there a way to get text content of the current node, not the descendant's text.</p>
  
  <p>Example </p>
  
  <pre><code>&lt;paragraph&gt;
      &lt;link&gt;XML&lt;/link&gt;
      is a 
      &lt;strong&gt;browser based XML editor&lt;/strong&gt;
      editor allows users to edit XML data in an intuitive word processor.
  &lt;/paragraph&gt;
  </code></pre>
  
  <p>expected output</p>
  
  <pre><code>paragraph = is a editor allows users to edit XML data in an intuitive word processor.
  link = XML
  strong = browser based XML editor
  </code></pre>
  
  <p>i tried below code</p>
  
  <pre><code>String str =            "&lt;paragraph&gt;"+
                              "&lt;link&gt;XML&lt;/link&gt;"+
                              " is a "+ 
                              "&lt;strong&gt;browser based XML editor&lt;/strong&gt;"+
                              "editor allows users to edit XML data in an intuitive word processor."+
                          "&lt;/paragraph&gt;";
  
          org.w3c.dom.Document domDoc = null;
          DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder docBuilder;
  
          try {
              docBuilder = docFactory.newDocumentBuilder();
              ByteArrayInputStream bis = new ByteArrayInputStream(str.getBytes());
              domDoc = docBuilder.parse(bis);         
          } catch (ParserConfigurationException e1) {         
              e1.printStackTrace();
          } catch (SAXException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }       
  
          DocumentTraversal traversal = (DocumentTraversal) domDoc;
          NodeIterator iterator = traversal.createNodeIterator(
                  domDoc.getDocumentElement(), NodeFilter.SHOW_ELEMENT, null, true);
  
          for (Node n = iterator.nextNode(); n != null; n = iterator.nextNode()) {           
              String tagname = ((Element) n).getTagName();
              System.out.println(tagname + "=" + ((Element)n).getTextContent());
          }
  </code></pre>
  
  <p>but it gives the output like this</p>
  
  <pre><code>paragraph=XML is a browser based XML editoreditor allows users to edit XML data in an intuitive word processor.
  link=XML
  strong=browser based XML editor
  </code></pre>
  
  <p>note the <strong>paragraph</strong> element contains the text of <strong>link</strong> and <strong>strong</strong> tag, which i dont want.
  please suggest some ideas?</p>