Java 无法使用Rome API从源读取图像URL
我正在使用罗马解析器解析我的RSS/Atom提要。现在的问题是,它没有给出新闻提要/条目的图像URL。问题的部分原因还在于提要不一致,并且它们放置图像URL的方式不一致 BBC新闻将图像url放入Java 无法使用Rome API从源读取图像URL,java,feed,rome,Java,Feed,Rome,我正在使用罗马解析器解析我的RSS/Atom提要。现在的问题是,它没有给出新闻提要/条目的图像URL。问题的部分原因还在于提要不一致,并且它们放置图像URL的方式不一致 BBC新闻将图像url放入元素中 <item> <title>Dementia in care homes 'more common'</title> <description>Eight out of 10 residents in care homes are n
元素中
<item>
<title>Dementia in care homes 'more common'</title>
<description>Eight out of 10 residents in care homes are now thought to have dementia or severe memory problems, new data shows.</description>
<link>http://www.bbc.co.uk/news/health-21579394#sa-ns_mchannel=rss&ns_source=PublicRSS20-sa</link>
<guid isPermaLink="false">http://www.bbc.co.uk/news/health-21579394</guid>
<pubDate>Tue, 26 Feb 2013 00:28:31 GMT</pubDate>
<media:thumbnail width="66" height="49" url="http://news.bbcimg.co.uk/media/images/66064000/jpg/_66064884_c0016428-geriatric_care-spl.jpg"/>
<media:thumbnail width="144" height="81" url="http://news.bbcimg.co.uk/media/images/66064000/jpg/_66064885_c0016428-geriatric_care-spl.jpg"/>
</item>
养老院痴呆症“更常见”
最新数据显示,目前有八成的养老院居民被认为患有痴呆症或严重的记忆问题。
http://www.bbc.co.uk/news/health-21579394#sa-ns_mchannel=rss&;ns_来源=PublicRSS20 sa
http://www.bbc.co.uk/news/health-21579394
2013年2月26日星期二00:28:31 GMT
但是一些新闻提要将图像放在附件元素中。有些订阅源根本没有
所以我的问题是,;如果它们出现在提要中,我如何获取它们。到目前为止,Rome API对我来说工作得很好;但是现在我被困在这个问题上。我可以找到从提要获取图像url的方法。部分问题是因为罗马不使用仿制药;因此无法阅读
List<Element> foreignMarkups = (List<Element>) entry.getForeignMarkup();
for (Element foreignMarkup : foreignMarkups) {
String imgURL = foreignMarkup.getAttribute("url").getValue();
//read width and height
}
List<SyndEnclosure> encls = entry.getEnclosures();
if(!encls.isEmpty()){
for(SyndEnclosure e : encls){
String imgURL = e.getUrl().toString();
}
}