javascriptxml2js

xml2js parsed result without attributes


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"
  }
}

Solution

  • 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.