安卓 RSS 阅读器 - 教程错误



我花了一天时间研究Android RSS阅读器。

我想在我的应用程序中解析一个非常简单的 XML 文件。 http://www.sportinglife.com/rss/transfer_wire.xml

此站点上有几个线程回答 RSS 问题,例如 https://stackoverflow.com/questions/1253788/simple-rss-parser-for-android。我已经尝试了其中的所有解决方案,但是在运行代码时,我在Eclipse中不断出现错误。

我找到了 2012 年 4 月的最新 IBM 教程,它很好地解释了代码,并在一个类文件中提供了一个解决方案。 http://www.ibm.com/developerworks/xml/library/x-androidxml/index.html

我已经逐步遵循了本教程,但是 Eclipse 抛出了以下错误:

[Dex Loader] Unable to execute dex: Unexpected magic: [100, 101, 120, 10, 48, 49, 51, 0]
[FootballTransfers] Conversion to Dalvik format failed: Unable to execute dex: Unexpected magic: [100, 101, 120, 10, 48, 49, 51, 0]

以前有人遇到过这个问题吗?我不知道这个错误是什么意思。

当我运行 https://stackoverflow.com/questions/1253788/simple-rss-parser-for-android 线程中提供的解决方案时,我收到同样的错误。

传递输入流而不是网址

 @Override
        protected Void doInBackground(String... urls) {
 arrayList = new NewsParser().getData(NewsMainActivity .this.getResources.openRawResourece(R.xml.feed));
            return null;
        }

并在getData方法中将参数更改为输入流。

 public List<NewsBean> getData(InputStream istream) {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance()
                    .newDocumentBuilder();
            System.out.println("Builder : " + builder);
            Document doc = builder.parse(istream);
    Document doc = builder.parse(istream);
.....
}

最新更新