I am trying to create the RSS Feeds using java ROME API. My requirement is that every entry should contain an Image as given below:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<title>Sample RSS Build Results</title>
<link>http://time.is</link>
<description>sample RSS build</description>
<item>
<title>Ist Feed</title>
<link>http://mysampleurl1.com</link>
<description>The build was successful!</description>
<pubDate>Mon, 08 Aug 2016 10:28:32 GMT</pubDate>
<image>http://myimageurl1.com</image>
<dc:date>2016-08-08T10:28:32Z</dc:date>
</item>
<item>
<title>IInd Feed</title>
<link>http://mysampleurl2.com</link>
<description>The build was successful!</description>
<pubDate>Mon, 08 Aug 2016 10:28:44 GMT</pubDate>
<dc:date>2016-08-08T10:28:44Z</dc:date>
</item>
</channel>
I am new to java ROME api. It provides the package :: com.rometools.rome.feed.synd.SyndImageImpl
to set/get image item in complete feed but not in individual entries. For an entry in RSS feed it has package :: com.rometools.rome.feed.synd.SyndEntryImpl
but it does not provide any function for setting or getting image.
Please help me to resolve this issue. Thanks in advance.
The RSS spec doesn't specify image elements for entries, but you can extend it with Image namespace.
Short solution could be like this:
This will result in valid xml:
More robust way is to create a custom module like they've done here and here.