Home > Net >  xml2js parsed result without attributes
xml2js parsed result without attributes

Time:03-07

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

E.g., for the input

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

I wish to get

"foo": "Bar"

Rather than

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

CodePudding user response:

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.

  • Related