Java dom读取XML文件中特殊字符-报错

2014-11-24 09:14:44 · 作者: · 浏览: 0

在用dom读取XML文件的时候,报错。

以下是错误:

[Fatal Error] A01.xml:6:53: The character reference must end with the ';' delimiter.
Exception in thread "main" org.xml.sax.SAXParseException: The character reference must end with the ';' delimiter.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:180)
at Parser.Parse(Parser.java:108)
at Parser.main(Parser.java:185)

类似的XML内容

Reduction Algorithm using the À TROUS Wavelet Transform.

解决方法:

遇到这样的特殊字符&#\d{1,4}[^;],

大家都应该替换一下:

String.replaceAll("À", "À");