我有一个读取 RSS 提要的简单代码。它曾经在给定的 RSS 提要上工作正常,但由于某种原因停止工作,出现以下异常:
Exception in thread "main" java.lang.IllegalArgumentException: Invalid document
at com.rometools.rome.io.WireFeedInput.build(WireFeedInput.java:312)
at com.rometools.rome.io.WireFeedInput.build(WireFeedInput.java:234)
at com.rometools.rome.io.SyndFeedInput.build(SyndFeedInput.java:150)
这是代码:
URL url = new URL("http://www.dpreview.com/feeds/reviews/latest");
XmlReader reader = null;
try {
reader = new XmlReader(url);
SyndFeed feeder = new SyndFeedInput().build(reader);
System.out.println("Feed Title: "+ feeder.getAuthor());
for (Iterator i = feeder.getEntries().iterator(); i.hasNext();) {
SyndEntry syndEntry = (SyndEntry) i.next();
System.out.println(syndEntry.getTitle());
}
} finally {
if (reader != null)
reader.close();
}
有什么我想念的吗?
蛊毒传说
相关分类