XML2JS conversion in nodejs

430 Views Asked by At

Hi I need one help When I am using xml2js node js lib. I am able to convert the XML to JSON object however when I am iterating JSON element I can see the '$': as few of the key elements. Is there a way I can eliminate the $ key ?

2

There are 2 best solutions below

1
On

try regex to replace the $ key

or

use JSON.parse() to replace the $.

0
On

You can use attrkey to change the $ key to sth else.

Or you can ignore it (do not create attribute node) with ignoreAttrs set to true

as per the readme of xml2js