Here you can find the source of unescapeFromXML(String string)
Parameter | Description |
---|---|
string | the string to unescape. |
public static final String unescapeFromXML(String string)
//package com.java2s; public class Main { /**/*from ww w . j a v a 2 s .com*/ * Unescapes the String by converting XML escape sequences back into normal * characters. * * @param string * the string to unescape. * @return the string with appropriate characters unescaped. */ public static final String unescapeFromXML(String string) { string = replace(string, "<", "<"); string = replace(string, ">", ">"); string = replace(string, """, "\""); return replace(string, "&", "&"); } /** * Replaces all instances of oldString with newString in line. */ public static final String replace(String line, String oldString, String newString) { int i = 0; if ((i = line.indexOf(oldString, i)) >= 0) { char[] line2 = line.toCharArray(); char[] newString2 = newString.toCharArray(); int oLength = oldString.length(); StringBuffer buf = new StringBuffer(line2.length); buf.append(line2, 0, i).append(newString2); i += oLength; int j = i; while ((i = line.indexOf(oldString, i)) > 0) { buf.append(line2, j, i - j).append(newString2); i += oLength; j = i; } buf.append(line2, j, line2.length - j); return buf.toString(); } return line; } }