title: How do I stop getNodeName() also printing the node type
body: <p>I'm stumped, hopefully I've just done a dumb thing that I can fix easily.  </p>
  
  <p>I'm passing in a String full of XML, being 'XMLstring'.  I want to get one of the elements and print the child nodes in a "name = value" on the console.  The problem is that the console keeps printing garbage along with the element name that I cannot work out how to get rid of.</p>
  
  <p>Anyway, this code:</p>
  
  <pre><code>try {
          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
          DocumentBuilder db = dbf.newDocumentBuilder();
          InputSource is = new InputSource();
          is.setCharacterStream(new StringReader(XMLstring));
          Document doc = db.parse(is);
  
          NodeList nodes = doc.getElementsByTagName("client-details");
          Node node = nodes.item(0);
  
          NodeList client_details = node.getChildNodes();
  
          for (int i = 0; i &lt; client_details.getLength(); i++) {
              System.out.println(client_details.item(i).getNodeName()+" = "+getTextContents(client_details.item(i)));
          }
      }
      catch (Exception e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Gives me the following:</p>
  
  <pre><code>#text = 
  testing-mode = false
  #text = 
  name = testman
  #text = 
  age = 30
  </code></pre>
  
  <p>Why is it printing the "#text ="?  How do I get rid of it?</p>
  
  <p>I am using NetBeans if that helps.</p>