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