Java tutorial
//package com.java2s; public class Main { public static String SPACE = " "; public static String QUOTE = "\""; public static String GT = ">"; public static String GT_A = ">"; public static String LT = "<"; public static String LT_A = "<"; public static String QUOTE_A = """; public static String APOS = "'"; public static String APOS_A = "'"; public static String AND = "&"; public static String AND_A = "&"; public static String NBSP_A = " "; public static String decodeXML(String XML) { String result = XML.replaceAll(LT_A, LT); result = result.replaceAll(GT_A, GT); result = result.replaceAll(QUOTE_A, QUOTE); result = result.replaceAll(APOS_A, APOS); result = result.replaceAll(AND_A, AND); result = result.replaceAll(NBSP_A, SPACE); /* * if(result.contains("amp;")){ log.severe("decodeXML Orig XML = "+XML); * log.severe("decodeXML Final XML = "+result); } */ /* * if(result.contains("&")){ * log.severe("decodeXML Final XML contains amp = "+result); } */ return result; } }