Java tutorial
//package com.java2s; public class Main { /** * <p> * Escapes XML reserved characters to their corresponding XML-safe versions. * Specifically, this method: * </p> * <xmp> Replaces & with & Replaces < with < Replaces > with > * </xmp> * * @param txt * Source string with text that needs to have XML characters * escaped * @return String that has reserved XML characters escaped */ public static String escapeXMLText(String txt) { return txt.replace("&", "&").replace("<", "<").replace(">", ">"); } }