I am working with some XML that holds strings like:
This is a string
Some of the strings that I am passing to the
In summary, valid characters in the text are:
&
and <
.>
is not valid if following ]]
.Sections 2.2 and 2.4 of the XML specification provide the answer in detail:
Characters
Legal characters are tab, carriage return, line feed, and the legal characters of Unicode and ISO/IEC 10646
Character data
The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings " & " and " < " respectively. The right angle bracket (>) may be represented using the string " > ", and must, for compatibility, be escaped using either " > " or a character reference when it appears in the string " ]]> " in content, when that string is not marking the end of a CDATA section.