Java tutorial
//package com.java2s; public class Main { public static String getAsTagValue(String value) { if (value != null && value.length() > 0) { // @author changes Medet, CDATA if (value.startsWith("<![CDATA[") && value.endsWith("]]>")) { return value; } // String val = value.replace("&", "&"); val = val.replace("\n", ""); val = val.replace("\"", "'"); val = val.replace("\r", ""); val = val.replace("\"", """); val = val.replace("<", "<").replace(">", ">"); return val; } else { return ""; } } }