node-xml2js icon indicating copy to clipboard operation
node-xml2js copied to clipboard

< inside attributes after converting json to xml

Open javratka opened this issue 5 years ago • 1 comments

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>

javratka avatar Apr 23 '20 20:04 javratka

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)

bevanweiss avatar Nov 28 '21 08:11 bevanweiss