Issue
I have XML document that I am trying to convert to JSON but some of the string fields have HTML tags in them. The source XML looks like this:
<title>
<html>
<p>test</p>
</html>
</title>
i have tried npm packages like xml2js and fast-xml-parser. They are parsing html tags also to json. can anyone suggest any other npm package or solution that would be helpful
Expected output should be:
{
"title": "<html><p>test</p></html>"
}
Solution
You can try fast-xml-parser with stopNodes option to parse a node as a string.
let jsonObj = parser.parse(xmlData,{
stopNodes = ["title"]
});
Answered By - Aman Garg
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.