I am trying to transform XML to XHTML. I have used XSLTProcessor in client side (Angular) and it's working fine. Now I am trying to use the same code in Node JS but it's not working and I am getting error message as XSLTProcessor undefined. Below is the client side code. Please suggest me the methods available for transformation in Node JS side.
transformXml(xml, xsl) {
var html;
if (this.isIE) {
html = xml.transformNode(xsl);
} else {
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
var xmlDom = xsltProcessor.transformToDocument(xml);
var serializer = new XMLSerializer();
html = serializer.serializeToString(xmlDom.documentElement);
}
return html;
}
XMLTProcessor() is not part of Node.js. You need a package like https://www.npmjs.com/package/xslt or similar - there are a number of packages for XSLT: https://www.npmjs.com/search?q=xslt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With