Escape XML String
Escape the XML value in a String.
Javadoc available at https://www.javatapas.com/docs/javatapas/string/EscapeXmlString.html
public static String escapeXmlString(String str){
// this must be done first or else the escapes below are over-written.
str = str.replaceAll("&","&");
str = str.replaceAll("<","<");
str = str.replaceAll(">",">");
str = str.replaceAll("\"\"",""");
str = str.replaceAll("\"",""");
str = str.replaceAll("'","'");
str = str.replaceAll("“",""");
str = str.replaceAll("’","'");
str = str.replaceAll("–","-");
return str;
}