title: Issue with XML child nodes iteration when mix of text and element nodes
body: <p>I was trying to parse following  strings to form a xml document and then trying to extract all child nodes of  and add to a different document object which is already available to me.</p>
  
  <pre><code>&lt;dhruba&gt;&lt;test&gt;this&lt;/test&gt;that&lt;test2&gt;wang chu&lt;/test2&gt; something.... &lt;/dhruba&gt;
  
  &lt;dhruba&gt;this is text node &lt;test&gt;this&lt;/test&gt;that&lt;test2&gt;wang chu&lt;/test2&gt; anything..&lt;/dhruba&gt;
  </code></pre>
  
  <p>while I am trying to read the child nodes, it is returning null child for TEXT_NODE for 1st string and null for ELEMENT_NODE for 2nd String, this is wrong, is it API problem ??</p>
  
  <p>I am using following code ... it compile , I am using java 6.</p>
  
  <pre><code>        Node n = null;
          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                  try {
                      db = dbf.newDocumentBuilder();
                  } catch (ParserConfigurationException e1) {
                      // TODO Auto-generated catch block
                      e1.printStackTrace();
                  }
                  dom = db.newDocument();
                  Element rootEle = dom.createElement("resources");
          // adding the root element to the document
          dom.appendChild(rootEle);
  
          Element element = dom.createElement("string");
  
          element.setAttribute("name", "some_name");
          try {
  
              n = db.parse(new InputSource(new StringReader("&lt;dhruba&gt;&lt;test&gt;this&lt;/test&gt;that&lt;test2&gt;node value&lt;/test2&gt; some text&lt;/dhruba&gt;"))).getDocumentElement();
              n = dom.importNode(n, true);
  
  
              NodeList nodeList = n.getChildNodes();
              int length = nodeList.getLength();
              System.out.println("Total no of childs : "+length);
              for(int count = 0 ; count &lt; length ; count++ ){
                  Node node = nodeList.item(count);
                  if(node != null ){
                      element.appendChild(node);
                  }
              }
          } catch (SAXException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          rootEle.appendChild(element);
  </code></pre>
  
  <p>INPUT ::  as string</p>
  
  <pre><code>             &lt;dhruba&gt;&lt;string name="some_name"&gt;
                          that
                          &lt;test&gt;this&lt;/test&gt;                             
                          &lt;test2&gt;node   value&lt;/test2&gt;
                          some text
                       &lt;/string&gt;
                &lt;/dhruba&gt;
  </code></pre>
  
  <p>EXPECTED OUTPUT ::  as document </p>
  
  <pre><code>               &lt;string&gt;
                   &lt;string name="some_name"&gt;
                              &lt;test&gt;this&lt;/test&gt;
                               &lt;test2&gt;node   value&lt;/test2&gt;
                   &lt;/string&gt;
                &lt;/string&gt;
  </code></pre>
  
  <p>if I try to parse </p>
  
  <pre><code>          &lt;test&gt;this&lt;/test&gt;that&lt;test2&gt;wang chu&lt;/test2&gt; something.... 
  </code></pre>
  
  <p>then output comes as "thiswang chu"</p>
  
  <pre><code>Why is this happening?  what needs to be done if I want to add following node under another document element, i.e. &lt;string&gt;.
      &lt;test&gt;this&lt;/test&gt;
                          that                             
                          &lt;test2&gt;node   value&lt;/test2&gt;
                          some text 
  [notice that it does not have &lt;dhruba&gt;] inside parent node of another 
  document.
  </code></pre>
  
  <p>Hope I am clear. Above code compiles in Java 6</p>