title: Resolving entities while parsing xml file in nodejs
body: <p>My xml file has </p>
  
  <pre><code>&lt;!DOCTYPE application [&lt;!ENTITY % common  SYSTEM "../common.ent"&gt;
  %common;]&gt;
  </code></pre>
  
  <p>and i have used <code>&amp;commonFaults;</code>, (which is one of the entities defined in <code>./common.ent</code> file), many where in the xml file</p>
  
  <p>in my node application i want to input the stringifed xml file content.
  and in return i want all the entities to be resolved.</p>
  
  <p>input</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
      &lt;!DOCTYPE application [&lt;!ENTITY % common  SYSTEM "../common.ent"&gt;
      %common;]&gt;
      &lt;application xmlns="http://wadl.dev.java.net/2009/02"&gt;
          &lt;grammars&gt;
              &lt;include href="../xsd/api.xsd"/&gt;
              &lt;include href="../xsd/api-common.xsd"/&gt;
          &lt;/grammars&gt;
          &lt;method name="GET" id="listVersionsv2"&gt;
               &amp;commonFaults;
          &lt;/method&gt;
      &lt;/application&gt;
  </code></pre>
  
  <p>common.ent file :</p>
  
  <pre><code> &lt;!ENTITY commonFaults
             '
          &lt;response status="503" xmlns="http://wadl.dev.java.net/2009/02"&gt;
              &lt;representation mediaType="application/xml" element="csapi:serviceUnavailable"/&gt;
              &lt;representation mediaType="application/json"/&gt;
          &lt;/response&gt;
          &lt;response status="400" xmlns="http://wadl.dev.java.net/2009/02"&gt;
              &lt;representation mediaType="application/xml" element="csapi:badRequest"/&gt;
              &lt;representation mediaType="application/json"/&gt;
          &lt;/response&gt;
             '&gt;
  </code></pre>
  
  <p>Desired output</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
      &lt;!DOCTYPE application [&lt;!ENTITY % common  SYSTEM "../common.ent"&gt;
      %common;]&gt;
      &lt;application xmlns="http://wadl.dev.java.net/2009/02"&gt;
          &lt;grammars&gt;
              &lt;include href="../xsd/api.xsd"/&gt;
              &lt;include href="../xsd/api-common.xsd"/&gt;
          &lt;/grammars&gt;
          &lt;method name="GET" id="listVersionsv2"&gt;
          &lt;response status="503" xmlns="http://wadl.dev.java.net/2009/02"&gt;
              &lt;representation mediaType="application/xml" element="csapi:serviceUnavailable"/&gt;
              &lt;representation mediaType="application/json"/&gt;
          &lt;/response&gt;
          &lt;response status="400" xmlns="http://wadl.dev.java.net/2009/02"&gt;
              &lt;representation mediaType="application/xml" element="csapi:badRequest"/&gt;
              &lt;representation mediaType="application/json"/&gt;
          &lt;/response&gt;
          &lt;/method&gt;
      &lt;/application&gt;
  </code></pre>
  
  <p>I search <code>xmllint</code> with <code>--noent</code> option which does this efficiently.</p>
  
  <p>I am looking for a similar lib/tool which does this as npm module, which i can 'require' in node application and accomplish the same task as <code>xmllint</code> does.</p>
  
  <p>I Do not want to use ChildProcess of node.</p>