“All Feeds Lead to ROME”

Recently I was introduced to ROME – the news feed utility, not the city. From the Rome web site:

&#8220 ROME is an open source (Apache license) set of Atom/RSS Java utilities that make it easy to work in Java with most syndication formats:

RSS 0.90, RSS 0.91 Netscape, RSS 0.91 Userland, RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0, RSS 2.0, Atom 0.3, and Atom 1.0

ROME includes a set of parsers and generators for the various flavors of syndication feeds, as well as converters to convert from one format to another. The parsers can give you back Java objects that are either specific for the format you want to work with, or a generic normalized SyndFeed class that lets you work on with the data without bothering about the incoming or outgoing feed type.

&#8221

Apparently ROME is an acronym for “RSS and Atom Utilities for Java” – a bit of a stretch if you ask me.

Anyway, if you can get past the stupid name it’s a great utility. The biggest advantage that it has going for it is its ability to provide a common set of Java objects: SyndFeed, SyndEntry for the different versions of RSS and Atom. You can point ROME at an RSS URL without having to know what schema the feed implements, and ROME will figure it out and run the XML file through the appropriate parser. Here’s an example of its use:

URL feedUrl = new URL("http://slashdot.org/index.rss");
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new InputStreamReader(feedUrl.openStream()));

// With a SyndFeed object you can get the link to the source site via: feed.getLink();
// The feed's title is accessed via: feed.getTitle();
// Include the feed's logo via: feed.getImage().getUrl();
// Include the feed's description via: feed.getDescription();

for (Iterator i = feed.getEntries().iterator(); i.hasNext();) {
  SyndEntry entry = (SyndEntry) i.next()));
  // A SyndEntry object represents an entry from the feed.
  // Typically you'd want to get the title and link for each entry like this:
  // entry.getLink();
  // entry.getTitle();

}

Anyway, I’ve written a couple of RSS feed readers in the past, one with a home grown Java implementation and another in php, but this was by far the simplest and fastest one to get working. We had our RSS feed reader working in under an hour. I’d highly recommend ROME. It’s really simple and it just plain works.

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply