XML2JS conversion in nodejs

420 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 answers

1
Ashok Kumar Thangaraj On

try regex to replace the $ key

or

use JSON.parse() to replace the $.

0
Tuan Anh Tran 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