使用 ROME 提取饲料内容?
如何使用 Java 中的 ROME 获取字符串形式的内容以获取某些提要。
目前这就是我得到的
String feedURL = “...”;
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
System.out.println(feed);
for (final Iterator iter = feed.getModules().iterator(); iter.hasNext();){
System.out.println("\t" + ((Module)iter.next()).getUri());
}
System.out.println("Titles of the " + feed.getEntries().size() + " entries:");
for (final Iterator iter = feed.getEntries().iterator(); iter.hasNext();){
System.out.println("\t" + ((SyndEntry)iter.next()).getContents());
}
然后它的输出是:
SyndContentImpl.interface=interface com.sun.syndication.feed.synd.SyndContent
SyndContentImpl.type=html
SyndContentImpl.mode=null
SyndContentImpl.value= <p><a href="http://www.flickr.com/people/64539367@N07/">MiscDot</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/64539367@N07/5954881384/" title="03a"><img src="http://farm7.static.flickr.com/6024/5954881384_5390838321_m.jpg" width="240" height="240" alt="03a" /></a></p>
但我想要的只是获取内容的字符串: SyndContentsImpl.value
How do I get the contents as a String using ROME in Java for some feed.
At the moment this is what I got
String feedURL = “...”;
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
System.out.println(feed);
for (final Iterator iter = feed.getModules().iterator(); iter.hasNext();){
System.out.println("\t" + ((Module)iter.next()).getUri());
}
System.out.println("Titles of the " + feed.getEntries().size() + " entries:");
for (final Iterator iter = feed.getEntries().iterator(); iter.hasNext();){
System.out.println("\t" + ((SyndEntry)iter.next()).getContents());
}
Then the output of this is:
SyndContentImpl.interface=interface com.sun.syndication.feed.synd.SyndContent
SyndContentImpl.type=html
SyndContentImpl.mode=null
SyndContentImpl.value= <p><a href="http://www.flickr.com/people/64539367@N07/">MiscDot</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/64539367@N07/5954881384/" title="03a"><img src="http://farm7.static.flickr.com/6024/5954881384_5390838321_m.jpg" width="240" height="240" alt="03a" /></a></p>
But what I want is to just get the string of the contents:SyndContentsImpl.value
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像...
Something like...