网上找了很多将 & 转换为 & ,的解码函数,大多数是字节写的.实际上有标准实现.导入下面的库.
import org.apache.commons.lang.StringEscapeUtils;
main()
{
String unescapedXML = "<data>";
System.err.println(
StringEscapeUtils.escapeXml(unescapedXML));
} String escapedXML = "<data>";
System.err.println(
StringEscapeUtils.unescapeXml(unescapedXML));