Java tutorial
//package com.java2s; public class Main { public static String escapeXml(String str) { str = str.replaceAll("&", "&"); str = str.replaceAll("<", "<"); str = str.replaceAll(">", ">"); str = str.replaceAll("\"", """); str = str.replaceAll("'", "'"); return str; } }