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 addition to potame's answer, if you do want to escape using a CDATA block.
If you put your text in a CDATA block then you don't need to use escaping. In that case you can use all characters in the following range:
Note: On top of that, you're not allowed to use the ]]>
character sequence. Because it would match the end of the CDATA block.
If there are still invalid characters (e.g. control characters), then probably it's better to use some kind of encoding (e.g. base64).