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