Escape un escape Xml
class Main{
public static String escapeXMLChars(String s) {
return s.replaceAll("&", "&")
.replaceAll("'", "'")
.replaceAll("\"", """)
.replaceAll("<", "<")
.replaceAll(">", ">");
}
public static String unescapeXMLChars(String s) {
return s.replaceAll("&", "&")
.replaceAll("'", "'")
.replaceAll(""", "\"")
.replaceAll("<", "<")
.replaceAll(">", ">");
}
}
Related examples in the same category