Leonidas-from-XIV / node-xml2js

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

Stop parsing into certain tag #503

Open user1020 opened 5 years ago

user1020 commented 5 years ago

Wonder if if there is an option when doing xml to json conversion, upon encountering a special tag, like htmlHere, it should stop parsing what's in the tag, treat the whole thing (with proper escaping) as a string?

For example xml

...
...
<htmlHere><p>this is line one</p><p>this is line two</p></htmlHere>
...

should be parsed to

...
"htmlHere": "<htmlHere><p>this is line one</p><p>this is line two</p></htmlHere>"

Thanks in advance.

Leonidas-from-XIV commented 5 years ago

In a way this is exactly what CDATA is meant for.

user1020 commented 5 years ago

The XML I need to parse has "htmlHere" tag with what appears to be html tags (like

) just as part of xml. Looks different from CDATA to me:

<script>
   <![CDATA[
      <message> Welcome to TutorialsPoint </message>
   ]] >
</script >

What do you think?