我在解析器xml文件中遇到异常,我搜索了一些有相同异常的问题,但我仍然没有找到解决方案:
我试图使用XmlPullParser
:
1。 Xml代码
<script type="text/template" class="sidebarTemplate">
<aside class="sidebar">
<ul>
<li class="sidebarDate">1 hour ago</li>
<!--
<li class="sidebarTags"><a href="http://xkcn.info/tagged/girl-xinh" class="sidebarTag">#girl xinh </a><a href="http://xkcn.info/tagged/pretty-girl" class="sidebarTag">#pretty girl </a><a href="http://xkcn.info/tagged/vietnam-girl" class="sidebarTag">#vietnam girl </a><a href="http://xkcn.info/tagged/beautiful-girl-photo" class="sidebarTag">#beautiful girl photo </a><a href="http://xkcn.info/tagged/photography" class="sidebarTag">#photography </a></span></li>
-->
<li class="sidebarShare">
<iframe src="//www.facebook.com/plugins/like.php?href=http://xkcn.info/post/125394864133/kieu-nga-by-thích-việt-hoàng-a-lot-more-at&width&layout=box_count&action=like&show_faces=false&share=false&height=65&width=55&appId=352683068141771" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:65px;width:55px" allowTransparency="true"></iframe>
<!--<ul>
<li>
<a href="https://www.tumblr.com/reblog/125394864133/CzhuMx8H" class="reblog_button"style="display: block;width:25px;height:25px;"><svg width="100%" height="100%" viewBox="0 0 21 21" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="#ccc"><path d="M5.01092527,5.99908429 L16.0088498,5.99908429 L16.136,9.508 L20.836,4.752 L16.136,0.083 L16.1360004,3.01110845 L2.09985349,3.01110845 C1.50585349,3.01110845 0.979248041,3.44726568 0.979248041,4.45007306 L0.979248041,10.9999998 L3.98376463,8.30993634 L3.98376463,6.89801007 C3.98376463,6.20867902 4.71892527,5.99908429 5.01092527,5.99908429 Z"></path><path d="M17.1420002,13.2800293 C17.1420002,13.5720293 17.022957,14.0490723 16.730957,14.0490723 L4.92919922,14.0490723 L4.92919922,11 L0.5,15.806 L4.92919922,20.5103758 L5.00469971,16.9990234 L18.9700928,16.9990234 C19.5640928,16.9990234 19.9453125,16.4010001 19.9453125,15.8060001 L19.9453125,9.5324707 L17.142,12.203"></path></svg></a>
</li>
<li>
<a href="http://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fxkcn.info%2Fpost%2F125394864133%2Fkieu-nga-by-th%C3%ADch-vi%E1%BB%87t-ho%C3%A0ng-a-lot-more-at" target="_blank"><i class="fa fa-facebook-square fa-2x"></i></a>
</li>
<li>
<a href="http://twitter.com/home?status=http%3A%2F%2Fxkcn.info%2Fpost%2F125394864133%2Fkieu-nga-by-th%C3%ADch-vi%E1%BB%87t-ho%C3%A0ng-a-lot-more-at" target="_blank"><i class="fa fa-twitter-square fa-2x"></i></a>
</li>
</ul>-->
</li>
</ul>
</aside>
</script>
2。分析代码
private void skip(XmlPullParser parser) throws XmlPullParserException, IOException {
if (parser.getEventType() != XmlPullParser.START_TAG) {
throw new IllegalStateException();
}
int depth = 1;
while (depth != 0) {
switch (parser.next()) {
case XmlPullParser.END_TAG:
depth--;
break;
case XmlPullParser.START_TAG:
depth++;
break;
}
}
}
第3。例外记录
XMLPullParserException org.xmlpull.v1.XmlPullParserException: unterminated entity ref (position:START_TAG <iframe src='sidebarShare'>@80:174 in java.io.InputStreamReader@5288e374)
我做了一些debug
并看到parser
下次调用时(我希望它指向iframe
标记 - &gt; exception
)
任何人都可以帮忙或给我一个建议吗?
谢谢!