title: Java: Ignoring escapes when parsing XML
body: <p>I'm using a DocumentBuilder to parse XML files. However, the specification for the project requires that within text nodes, strings like <code>&amp;quot;</code> and <code>&amp;lt;</code> be returned literally, and <em>not</em> decoded as characters (<code>"</code> and <code>&lt;</code>).</p>
  
  <p>A previous similar question, <a href="https://stackoverflow.com/questions/1979785/read-escaped-quote-as-escaped-quote-from-xml">Read escaped quote as escaped quote from xml</a>, received one answer that seems to be specific to Apache, and another that appears to simply not not do what it says it does. I'd love to be proven wrong on either count, however :)</p>
  
  <p>For reference, here is some code:</p>
  
  <pre><code>  file = new File(fileName);
    DocBderFac = DocumentBuilderFactory.newInstance();
    DocBder = DocBderFac.newDocumentBuilder();
    doc = DocBder.parse(file);
  
    NodeList textElmntLst = doc.getElementsByTagName(text);
    Element textElmnt = (Element) textElmntLst.item(0);
  
    NodeList txts = textElmnt.getChildNodes(); 
    String txt = ((Node) txts.item(0)).getNodeValue();
    System.out.println(txt);
  </code></pre>
  
  <p>I would like that println() to produce things like </p>
  
  <pre><code>&amp;quot;3&amp;gt;2&amp;quot;
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>"3&gt;2"
  </code></pre>
  
  <p>which is what currently happens.
  Thanks!</p>