June 25, 2009

Java RSS Example with Rome

« Maven Bundle Plugin - Create an OSGI bundle | Main | WSDL-first CXF-Client mit Maven und Spring »

Sometimes you need a RSS feed for your development process or for a special requirement in a project. The Java RSS Rome library enables the parsing and creation of RSS feeds at a Java environment. The following example describes a possible creation of an RSS feed.

String feedType = "rss_0.9";
String fileName = "rss.xml";

SyndFeed feed = new SyndFeedImpl();
feed.setFeedType(feedType);

feed.setTitle("Developers-Blog.org Feed");
feed.setLink("http://developers-blog.org");
feed.setDescription("");

List entries = new ArrayList();
SyndEntry entry;
SyndContent description;

entry = new SyndEntryImpl();
entry.setTitle("My first RSS example with Rome");
entry.setLink("http://developers-blog.org/...");
entry.setPublishedDate(DATE_PARSER.parse("2009-06-25"));
description = new SyndContentImpl();
description.setType("text/html");
description.setValue("<p>Haha: nothing here</p>");
entry.setDescription(description);
entries.add(entry);

feed.setEntries(entries);

Writer writer = new FileWriter(fileName);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed,writer);
writer.close();

Regards
Rafael Sobek

Technorati Tags:

Posted by rafael.sobek at 5:54 AM in Uncategorized

 

[Trackback URL for this entry]

Comment: Oifan at Mo, 4 Okt 8:14 PM

Next time you add an example, please provide valid Java class -- this fragment is missing imports and DATE_PARSER is undefined.

Your comment:

(not displayed)
 
 
 

Live Comment Preview:

 
« June »
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
282930