Java tutorial
//package com.java2s; public class Main { /** return version of the string that is ready for xml output (i.e. convert '<' to '<', etc) */ public static String xmlSafe(String s) { String safeString = s; safeString = safeString.replaceAll("&", "&"); safeString = safeString.replaceAll("<", "<"); safeString = safeString.replaceAll(">", ">"); safeString = safeString.replaceAll("'", "'"); safeString = safeString.replaceAll("\"", """); return safeString; } }