0

我花了一天时间研究 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线程中提供的解决方案时,我得到了同样的错误。

4

1 回答 1

1

传递输入流而不是 url

 @Override
        protected Void doInBackground(String... urls) {

 arrayList = new NewsParser().getData(NewsMainActivity .this.getResources.openRawResourece(R.xml.feed));

            return null;
        }

并在 getData 方法中将参数更改为 InputStream。

 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);
.....
}
于 2012-05-29T18:04:32.643 回答