Saturday, April 12, 2014

Programmer Tools: XML Escape & UnEscape

Original Text:  

Result:


Explanation
The following characters are reserved in XML content, and must be escaped and replaced with their corresponding XML entities.
' is replaced with '
" is replaced with "
& is replaced with &
< is replaced with <
> is replaced with >
In the XML attribute, except above characters, we need replace the following additional characters:
\t is replaced with
\n is replaced with
\r is replaced with

Resources
Guava XmlEscapers http://en.wikipedia.org/wiki/Valid_characters_in_XML

No comments:

Post a Comment