如何逃避SAX解析特殊字符 [英] How to escape the special char in SAX parsing
问题描述
我解析下面的XML文件:
I am parsing the xml file below:
<description>
<p>
<a href="http://news.yahoo.com/jessica-chastain-talks-princess-diana-biopic- 164102608.html">
<img src="http://l3.yimg.com/bt/api/res/1.2/zD3Iwxezk8JVGQwhow7y4Q--/YXBwaWQ9eW5ld3M7Zmk9ZmlsbDtoPTg2O3E9ODU7dz0xMzA-/http://media.zenfs.com/en_us/News/Reuters/2011-11-07T171906Z_01_BTRE7A61C3Y00_RTROPTP_2_FILM-US-JESSICACHASTAIN.JPG"
alt="photo"
align="left"
title="Actress Chastain poses for photographers as she arrives on the "Wilde Salome" red carpet at the 68th Venice Film Festival" border="0" />
</a>NEW YORK (TheWrap.com) - Jessica Chastain may not win Oscar gold this year, but it appears she will wear a crown.
</p>
<br clear="all"/>
</description>
我使用SAX解析器,并试图获得 IMG 标签,title属性里面的数据。但由于特殊字符的莎乐美野在文本我收到ExpatParser例外。
能否请你让我知道这可怎么解决?
I am using SAX parser and trying to get the data inside the img tag, title attribute. But because of the special char "Wild Salome" in the text i am getting ExpatParser exception. Could you please let me know how this can be solved?
推荐答案
中的XML是无效的。属性值不应包含引号()生成就应更换内
程序
字符&放大器; QUOT;
。
The XML is invalid. Attribute value should not contain quotes ("
). The program that generated it should replace the inner "
characters with "
.
如果您打印&放大器; QUOT;
来一个网页时,浏览器会自动显示字符数限制的它的位置。
If you print the "
to a webpage, the browser will automatically show "
-character on its place.
这篇关于如何逃避SAX解析特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!