2016-06-09 12 views
0

Meine Frage fast die gleiche wie es in dem Thema ist, fand ich - Unable to read image URL from feed using Rome API außer 2 Bedingungen. Also, wie Bild-URL zu lesen:Kann Bild-URL von RSS mit Rom API nicht lesen

<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&amp;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> 

Wenn doen't Markup Bild url info

List<Element> foreignMarkups = (List<Element>) entry.getForeignMarkup(); 
for (Element foreignMarkup : foreignMarkups) { 
    String imgURL = foreignMarkup.getAttribute("url").getValue(); 
    //read width and height 
} 

und entry.getEnclosures() enthalten. Außerdem habe ich im debug-Modus die Eintragsstruktur betrachtet und keine Bild-URL gefunden. Thumbnail namespases in dieser Struktur

Antwort

0

Versuchen Rome's media module URLS zu lesen:: Ich kann nur Medien sehen

import com.rometools.modules.mediarss.MediaEntryModule; 
import com.rometools.modules.mediarss.types.Thumbnail; 
import com.rometools.rome.feed.module.Module; 
... 
for (Module module : entry.getModules()) { 
    if (module instanceof MediaEntryModule) { 
     MediaEntryModule media = (MediaEntryModule)module; 
     for (Thumbnail thumb : media.getMetadata().getThumbnail()) { 
      System.out.println(thumb.getUrl()); 
     } 
    } 
} 

Sie rome-modules in Ihrem Classpath müssen für diese arbeiten.