在 java/rome 中读取 RSS 提要:无法访问 org.jdom.Document
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10267087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reading RSS feeds in java/rome: cannot access org.jdom.Document
提问by nasir
I am trying to read RSS feed in java I am using ROME to read the feed, but getting an error cannot access org.jdom.Document class file for org.jdom.Document not found SyndFeed feed = new SyndFeedInput().build(reader); 1 error
我正在尝试在 Java 中读取 RSS 提要我正在使用 ROME 来读取提要,但出现错误无法访问 org.jdom.Document 的 org.jdom.Document 类文件未找到 SyndFeed feed = new SyndFeedInput().build(reader ); 1 错误
I have added the jdom to the lib but still am getting the error. kindly guide me how to solve it. my code is as follows
我已将 jdom 添加到 lib 中,但仍然出现错误。请指导我如何解决它。我的代码如下
import java.net.URL;
import java.util.Iterator;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
public class Reader {
public static void main(String[] args) throws Exception {
URL url = new URL("http://viralpatel.net/blogs/feed");
XmlReader reader = null;
try {
reader = new XmlReader(url);
SyndFeed feed = new SyndFeedInput().build(reader);
System.out.println("Feed Title: "+ feed.getAuthor());
for (Iterator i = feed.getEntries().iterator(); i.hasNext();) {
SyndEntry entry = (SyndEntry) i.next();
System.out.println(entry.getTitle());
}
} finally {
if (reader != null)
reader.close();
}
}
}
回答by ZeroOne
回答by tushar_sappal
I would recommend to go through this web page , here you will find the working code to read and create RSS Feeds
我建议浏览这个网页,在这里你会找到阅读和创建 RSS 提要的工作代码
http://www.vogella.com/articles/RSSFeed/article.html
http://www.vogella.com/articles/RSSFeed/article.html
courtesy :-vogella.com
礼貌:-vogella.com
He does not uses the Rome for fetching the RSS Feeds but uses the set of custom built classes that help in creating and fetching the RSS feeds from the Web server
他没有使用 Rome 来获取 RSS 提要,而是使用一组自定义构建的类来帮助创建和从 Web 服务器获取 RSS 提要