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