Getting SAXParser to ignore escape characters

I am using sax parser to parse an xml file. It works perfectly except for when it comes across escape characters. Below is a the text in my xml file that I am trying to parse:

<line id='1'><![CDATA[Samantha saves 60&cent; on Thursday.]]></line>
<line id='2'><![CDATA[She saves 30&cent; on Friday.]]></line>

The result I get is: Samantha saves 60&"cent; on Thursday.She saves 30&"cent; on Friday.

How can I get my parser to ignore the & symbol? Is this possible?

EDIT: The above result is without the quotation marks. I dont want to have the & symbol after the number 60.


The CDATA tags are telling the parser that all characters within the CDATA sections are to be interpreted literally, that is, they represent themselves. So & within CDATA is not a special character; there are no escape sequences within CDATA. If you want to use entity references like &cent; then you shouldn't be using CDATA. What purpose are the CDATA tags fulfilling otherwise? Just get rid of them.

链接地址: http://www.djcxy.com/p/34916.html

上一篇: Java在JAXB解析之前无法解决XML / HTML问题

下一篇: 让SAXParser忽略转义字符