Here you can find the source of unescapeXMLString(String str)
public static String unescapeXMLString(String str)
//package com.java2s; //License from project: LGPL public class Main { public static String unescapeXMLString(String str) { StringBuffer rtn = new StringBuffer(); int posStart = -1; int posFinish = -1; while ((posStart = str.indexOf('&', posStart)) != -1) { int last = posFinish + 1; posFinish = str.indexOf(';', posStart); if (posFinish == -1) break; rtn.append(str.substring(last, posStart)); if (posStart + 1 < posFinish) { rtn.append(unescapeXMLEntity(str.substring(posStart + 1, posFinish))); } else { rtn.append("&;"); }//w w w . j av a 2s . c o m posStart = posFinish + 1; } rtn.append(str.substring(posFinish + 1)); return rtn.toString(); } private static String unescapeXMLEntity(String str) { if ("lt".equals(str)) return "<"; if ("gt".equals(str)) return ">"; if ("amp".equals(str)) return "&"; if ("apos".equals(str)) return "'"; if ("quot".equals(str)) return "\""; return "&" + str + ";"; } }