Parsing/Reading RSS/Atom Feed Using ROME

ROME library contains utility classes for parsing and publishing syndicated feeds, it is an open source Java library that make it easy to work with RSS/Atom feeds.

Rome library have converters to convert from one format to another. Rome can parse any format of Newsfeed, including RSS variants and Atom.

It will support most of the syndication formats includes following

  1. RSS 0.90
  2. RSS 0.91 Netscape
  3. RSS 0.91 Userland
  4. RSS 0.92
  5. RSS 0.93
  6. RSS 0.94
  7. RSS 1.0
  8. RSS 2.0
  9. Atom 0.3
  10. Atom 1.0

Note : Download ROME and JDOM

Parsing/Reading RSS/Atom Example


import java.net.URL;
import java.util.Iterator;

import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;

public class Reader {

public static void main(String[] args) throws Exception {

URL url  = new URL("https://javamagic.wordpress.com/feed/");
XmlReader reader = null;

try {

reader = new XmlReader(url);
SyndFeed feed = new SyndFeedInput().build(reader);
System.out.println("Feed Title: "+ feed.getAuthor());

for (Iterator i = feed.getEntries().iterator(); i.hasNext();) {
SyndEntry entry = (SyndEntry) i.next();
System.out.println(entry.getTitle());
}
} finally {
if (reader != null)
reader.close();
}
}
}

Hope you will like this. Cheers.. 🙂