Object resolution when parsing xml file in nodejs
My XML file has
<!DOCTYPE application [<!ENTITY % common SYSTEM "../common.ent">
%common;]>
and I used &commonFaults;
, (which is one of the entities defined in the file ./common.ent
) many of which are in the XML file
in my node app I want to inject the string content of the xml file. and in return I want all objects to be resolved.
entrance
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application [<!ENTITY % common SYSTEM "../common.ent">
%common;]>
<application xmlns="http://wadl.dev.java.net/2009/02">
<grammars>
<include href="../xsd/api.xsd"/>
<include href="../xsd/api-common.xsd"/>
</grammars>
<method name="GET" id="listVersionsv2">
&commonFaults;
</method>
</application>
common.ent file:
<!ENTITY commonFaults
'
<response status="503" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="csapi:serviceUnavailable"/>
<representation mediaType="application/json"/>
</response>
<response status="400" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="csapi:badRequest"/>
<representation mediaType="application/json"/>
</response>
'>
Desired output
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application [<!ENTITY % common SYSTEM "../common.ent">
%common;]>
<application xmlns="http://wadl.dev.java.net/2009/02">
<grammars>
<include href="../xsd/api.xsd"/>
<include href="../xsd/api-common.xsd"/>
</grammars>
<method name="GET" id="listVersionsv2">
<response status="503" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="csapi:serviceUnavailable"/>
<representation mediaType="application/json"/>
</response>
<response status="400" xmlns="http://wadl.dev.java.net/2009/02">
<representation mediaType="application/xml" element="csapi:badRequest"/>
<representation mediaType="application/json"/>
</response>
</method>
</application>
I am looking xmllint
with an option --noent
that does this efficiently.
I am looking for a similar lib / tool that does this as an npm module that I can "require" in a node application and does the same task as xmllint
.
I dont want to use ChildProcess node.
source to share
No one has answered this question yet
See similar questions:
or similar: