简体   繁体   中英

xml2js parsed result without attributes

Using xml2js , what is the way to parse XML and return a result without the XML attributes?

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. Look at the options section in the documantation for referance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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