Android org.xml.sax.SAXParseException:意外的令牌

时间:2014-10-15 10:44:33

标签: android xml android-asynctask

当我的应用程序从我的网站下载XML Feed时,有时会得到它并且同时生成此错误:

  

10-15 12:26:33.295 28032-28372 / it.pucillo.sampo.infodisilvio   W / System.err:org.xml.sax.SAXParseException:意外的令牌   (职位:TEXT } [oI ... @ 1:87 in   java.io.InputStreamReader@41f3b510)10-15 12:26:33.295   28032-28372 / it.pucillo.sampo.infodisilvio W / System.err:at   org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:146)   10-15 12:26:33.295 28032-28372 / it.pucillo.sampo.infodisilvio   W / System.err:at   it.pucillo.sampo.infodisilvio.MyActivity $ rss.doInBackground(MyActivity.java:489)   10-15 12:26:33.295 28032-28372 / it.pucillo.sampo.infodisilvio   W / System.err:at   it.pucillo.sampo.infodisilvio.MyActivity $ rss.doInBackground(MyActivity.java:472)   10-15 12:26:33.295 28032-28372 / it.pucillo.sampo.infodisilvio   W / System.err:在android.os.AsyncTask $ 2.call(AsyncTask.java:288)10-15   12:26:33.295 28032-28372 / it.pucillo.sampo.infodisilvio W / System.err:   at java.util.concurrent.FutureTask.run(FutureTask.java:237)10-15   12:26:33.295 28032-28372 / it.pucillo.sampo.infodisilvio W / System.err:   在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:231)10-15   12:26:33.295 28032-28372 / it.pucillo.sampo.infodisilvio W / System.err:   在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)   10-15 12:26:33.295 28032-28372 / it.pucillo.sampo.infodisilvio   W / System.err:at   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:587)   10-15 12:26:33.295 28032-28372 / it.pucillo.sampo.infodisilvio   W / System.err:at java.lang.Thread.run(Thread.java:841)

这是我的AsyncTask的代码:

@Override
        protected String doInBackground(String... params) {
            try {

                URL url = new URL(feedUrl);
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setConnectTimeout(30000);

                if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                    InputStream is = conn.getInputStream();
                    InputSource xs= new InputSource(is);

                    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                    DocumentBuilder db = dbf.newDocumentBuilder();
                    Document document = db.parse(xs);
                    elementi = document.getDocumentElement();
                }

            } catch (Exception e) {

                e.printStackTrace();

            }
            return "Executed";
        }

0 个答案:

没有答案