Parsing/Reading RSS/Atom Feed Using ROME
February 24, 2012 Leave a comment
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
- 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
- Atom 1.0
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.. 🙂
Recent Comments