Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.88k stars 602 forks source link

Parser is not able to parse the <![CDATA[ #519

Open Abhishek2kr opened 5 years ago

Abhishek2kr commented 5 years ago

So there should be option so that we can pass for parsing the multiple <![CDATA[

knoxcard commented 5 years ago

Are you using the most recent version of xml2js?

Yarn

yarn upgrade xml2js

NPM

npm update xml2js

Please confirm when possible....thanks!

t0lik commented 5 years ago

Are you using the most recent version of xml2js?

Only the builder has this option but not the parser

knoxcard commented 5 years ago

@Abhishek2kr - you gave my answer a thumbs up, did that work for you? Please let us know when you can...

If all good, please close issue...

Thanks!

Abhishek2kr commented 5 years ago

My npm version is 6.4.1 I have not updated the npm. And the xml2js version is 0.4.4

knoxcard commented 5 years ago

npm update xml2js - should just update xml2js, not npm itself...

https://stackoverflow.com/questions/43127863/node-update-a-specific-package

Abhishek2kr commented 5 years ago

I have just updated the xml2js still not working. I think we should create option for parser, similar to cdata option used in builder.

mwillbanks commented 4 years ago

I was running into this as well, I was looking to make a PR for this but don't have time yet... If you include this in the parser options, it will remove it, note the indexOf is really there for performance reasons since most xml feeds don't use cdata on all attributes.

  valueProcessors: [
    (value) => {
      if (value.indexOf('<![CDATA[') !== -1) {
        return value.replace(/\<\!\[CDATA\[([\s|\S]*)\]\]\>/i, "$1");
      }
      return value;
    },
  ]
anouarElazzaouy commented 4 years ago

it's handled in the last versions, all need to do is to update the package