I am working with some XML that holds strings like:
This is a string
Some of the strings that I am passing to the
For Java folks, Apache has a utility class (StringEscapeUtils) that has a helper method escapeXml which can be used for escaping characters in a string using XML entities.
StringEscapeUtils
escapeXml