没有属性的xml2js解析结果

xml2js parsed result without attributes

使用 xml2js,如何解析 XML 和 return 没有 XML 属性的结果?

例如,对于输入

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

我想得到

"foo": "Bar"

而不是

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

在您的 Parser 对象中设置选项 ignoreAttrs: true。它将忽略所有 XML 属性。查看文档中的 options section 以供参考。