Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android XmlPullParserException:读取inputStream时未终止的实体引用_Android_Xml_Xmlpullparser - Fatal编程技术网

Android XmlPullParserException:读取inputStream时未终止的实体引用

Android XmlPullParserException:读取inputStream时未终止的实体引用,android,xml,xmlpullparser,Android,Xml,Xmlpullparser,我发现解析器xml文件出现异常,我搜索了一些问题,但仍然没有找到解决方案: 我试图使用XmlPullParser忽略xml文件中的以下代码: 1。Xml代码 <script type="text/template" class="sidebarTemplate"> <aside class="sidebar"> <ul> <li class="sidebarDate">1 ho

我发现解析器xml文件出现异常,我搜索了一些问题,但仍然没有找到解决方案:

我试图使用
XmlPullParser
忽略xml文件中的以下代码:

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&amp;width&amp;layout=box_count&amp;action=like&amp;show_faces=false&amp;share=false&amp;height=65&amp;width=55&amp;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>
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)
XMLPullParserException org.xmlpull.v1.XMLPullParserException:unterminated entity ref(在java.io中的位置:START_TAG@80:174)。InputStreamReader@5288e374)
我做了一些
debug
并看到当
parser
调用next时(我希望它指向
iframe
标记-->
异常发生)
有谁能帮我或给我一个建议?

谢谢

我刚刚用“xmllint”实用程序成功地解析了它,并且在手动读取时没有看到错误。我会尝试使用其他一些XML工具对其进行解析,以确定这是文档中的问题,还是xmlpullparser中的问题。另外,尝试删除“src”属性,看看这是否能缩小问题的范围。我刚刚用“xmllint”实用程序成功地解析了它,在手动读取时没有看到错误。我会尝试使用其他一些XML工具对其进行解析,以确定这是文档中的问题,还是xmlpullparser中的问题。另外,尝试删除“src”属性,看看这是否能缩小问题的范围。