问题描述
我写一个小屏幕抓取应用程序,消耗一些XHTML - 不用说,XHTML是无效的:&符号不转义为&放大器;放大器;
I am writing a little screen-scraping app that consumes some XHTML - it goes without saying that the XHTML is invalid: ampersands aren't escaped as &
.
我使用Android的 XmlPullParser
,并在不正确的连接codeD值喷出了以下错误:
I am using Android's XmlPullParser
and it spews out the following error upon the incorrectly encoded value:
org.xmlpull.v1.XmlPullParserException: unterminated entity ref
(position:START_TAG <a href='/Fahrinfo/bin/query.bin/dox?ld=0.1&n=3&i=9c.0323581.1266265347&rt=0&vcra'>
@55:134 in java.io.InputStreamReader@43b1ef70)
我如何解决这个问题呢?我曾经想过以下解决方案:
How do I get around this? I have thought about the following solutions:
- 中包装
的InputStream
在另外一个替换&符号与实体裁判 - 配置解析器,因此奇迹般地接受了不正确的标记
- Wrapping the
InputStream
in another one that replaces the ampersands with entity refs - Configuring the Parser so it magically accepts the incorrect markup
哪一些可能是更成功?
推荐答案
我将与你的第一个选项去,替换&符号似乎更比其他一个合适的解决方案。第二个选择似乎更多的是破解的得到它,接受不正确的标记工作。
I would go with your first option, replacing the ampersands seems more of a fit solution than the other. The second option seems more of a hack to get it to work by accepting incorrect markup.
这篇关于解析无效的&符号与Android的XmlPullParsers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!