简体   繁体   English

没有属性的xml2js解析结果

[英]xml2js parsed result without attributes

Using xml2js , what is the way to parse XML and return a result without the XML attributes?使用xml2js ,如何解析 XML 并返回没有 XML 属性的结果?

Eg, for the input例如,对于输入

<foo type="attr">bar</completion_date>

I wish to get我希望得到

"foo": "Bar"

Rather than而不是

"foo": {
  "_": "bar",
  "$": {
    "type": "attr"
  }
}

Set option ignoreAttrs: true in your Parser object. The it will ignore all XML attributes.在您的Parser object 中设置选项ignoreAttrs: true 。它将忽略所有 XML 属性。 Look at the options section in the documantation for referance.查看文档中的选项部分以供参考。

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

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