I have an XML document with a tag that contains a user entered message, I would like to avoid unnecessary escaping of characters.
According to the link below the only strictly illegal characters are "<" and "&".
Note: Only the characters "<" and "&" are strictly illegal in XML. The greater than character is legal, but it is a good habit to replace it.
But in some parsers i encountered problems with the sequence ]]>, is this due to problems with the parsers or is it really defined as illegal somewhere in the XML-standard?
Example message:
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<message><!-- -- -- <![CDATA["TEST"]]></message>
<signature>Evil</signature>
</root>
As you can see < and & are escaped and this message is successfully parsed by C++ tinyxml and Java JAXB. Both Firefox 20.0.1 and IE 8.0 tell me
XML Parsing Error: not well-formed
and
The literal string ']]>' is not allowed in element content.
respectively.
Is this really a standard enforced behavior?
EDIT: Should have searched some more it seems, Legally use CDATA in XML. So I guess the XML parser in Firefox and IE are just broken?