Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy are there #text nodes in my xml file?
    text
    copied!<p>I'm making an android application that does DOM parsing on an xml file. I have an xml file that looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;family&gt; &lt;grandparent&gt; &lt;parent1&gt; &lt;child1&gt;Foo&lt;/child1&gt; &lt;child2&gt;Bar&lt;/child2&gt; &lt;/parent1&gt; &lt;parent2&gt; &lt;child1&gt;Raz&lt;/child1&gt; &lt;child2&gt;Mataz&lt;/child2&gt; &lt;/parent2&gt; &lt;/grandparent&gt; &lt;/family&gt; </code></pre> <p>If I run a dom parser on it, like this:</p> <pre><code>try { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.parse(input); doc.getDocumentElement().normalize(); //added in since the edit NodeList nodd = doc.getElementsByTagName("grandparent"); for (int x = 0; x &lt; nodd.getLength(); x++){ Node node = nodd.item(x); NodeList nodes = node.getChildNodes(); for(int y = 0; y &lt; nodes.getLength(); y++){ Node n = nodes.item(y); System.out.println(n.getNodeName()); } } } </code></pre> <p>My application prints out the following</p> <blockquote> <p>07-20 18:24:28.395: INFO/System.out(491): #text</p> <p>07-20 18:24:28.395: INFO/System.out(491): parent1 </p> <p>07-20 18:24:28.395: INFO/System.out(491): #text </p> <p>07-20 18:24:28.395: INFO/System.out(491): parent2 </p> <p>07-20 18:24:28.395: INFO/System.out(491): #text</p> </blockquote> <p>My question is, what are those #text fields and more importantly, how do I get rid of them?</p> <p><strong>Edit:</strong> So now that I know what they are, I tried to normalize it. I have updated the code to reflect the changes, but same result.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload