Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.87k stars 601 forks source link

< inside attributes after converting json to xml #567

Open javratka opened 4 years ago

javratka commented 4 years ago

I am converting a json into an xml using option cdata set to true. All tags apear correctly, except the '<' character situated inside the tags attributes that is replaces with '<'. The character '>' is not replaced and is correct. For example json like this: { "foo": { "$": { "name": "Some text here with inside <> characters" } } is going to be builded to xml like this: <foo name="Some text here with inside &lt;> characters"></foo>

bevanweiss commented 2 years ago

Are you sure that this doesn't comply to the XML v1 spec? https://www.w3.org/TR/xml/#syntax

It seems to indicate that exactly what you say is happening should happen... The < MUST be replaced with < The < may be replaced (but does not have to be, unless it appears to be a terminator for a CDATA section when it is not actually a terminator for a CDATA section.. then it MUST be replaced)