问题
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>
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?
回答1:
The XML is invalid. Attribute value should not contain quotes ("
). The program that generated it should replace the inner "
characters with "
.
If you print the "
to a webpage, the browser will automatically show "
-character on its place.
来源:https://stackoverflow.com/questions/8046898/how-to-escape-the-special-char-in-sax-parsing