简体   繁体   English

nodejs中的XML2JS转换

[英]XML2JS conversion in nodejs

Hi I need one help When I am using xml2js node js lib.嗨,当我使用 xml2js 节点 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. 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?有没有办法可以消除 $ 键?

try regex to replace the $ key尝试正则表达式替换 $ 键

or或者

use JSON.parse() to replace the $.使用 JSON.parse() 替换 $。

You can use attrkey to change the $ key to sth else.您可以使用attrkey$键更改为其他。

Or you can ignore it (do not create attribute node) with ignoreAttrs set to true或者您可以忽略它(不创建属性节点),将ignoreAttrs设置为true

as per the readme of xml2js根据xml2js 的自述文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM