Parsing/Reading RSS/Atom Feed Using ROME

Parsing / Reading RSS / Atom Feed Using ROME Tutorial describes about How to parse / read RSS / Atom feed using ROME API.
ROME is an open source java library that contains different utility classes and methods for parsing and publishing syndicated feeds, By using ROME API makes it very easily compliance with most of the RSS / Atom and syndication feeds.
Rome library contains lot of converters to convert from one format to another. Rome will parse any format of News feeds, including RSS variants and Atom
Below you can see an example of ROME API which parses the given google's feed burner link
http://feeds.feedburner.com/javatipsfeed
Rome can 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
Required Libraries
You need to download
- OpenJDK 8 / Corretto
- ROME (Rome Download)
- 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;
// Parsing/Reading RSS/Atom Feed With ROME API
public class AtomReader {
public static void main(String[] args) throws Exception {
URL url = new URL("http://feeds.feedburner.com/javatipsfeed");
XmlReader xmlReader = null;
try {
xmlReader = new XmlReader(url);
SyndFeed feeder = new SyndFeedInput().build(xmlReader);
System.out.println("Title Value " + feeder.getAuthor());
for (Iterator iterator = feeder.getEntries().iterator(); iterator
.hasNext();) {
SyndEntry syndEntry = (SyndEntry) iterator.next();
System.out.println(syndEntry.getTitle());
}
} finally {
if (xmlReader != null)
xmlReader.close();
}
}
}
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;
// Parsing/Reading RSS/Atom Feed With ROME API
public class AtomReader {
public static void main(String[] args) throws Exception {
URL url = new URL("http://feeds.feedburner.com/javatipsfeed");
XmlReader xmlReader = null;
try {
xmlReader = new XmlReader(url);
SyndFeed feeder = new SyndFeedInput().build(xmlReader);
System.out.println("Title Value " + feeder.getAuthor());
for (Iterator iterator = feeder.getEntries().iterator(); iterator
.hasNext();) {
SyndEntry syndEntry = (SyndEntry) iterator.next();
System.out.println(syndEntry.getTitle());
}
} finally {
if (xmlReader != null)
xmlReader.close();
}
}
}
Output
fn:join() JSTL Function HttpSessionListener Example Ireport Download JSTL For Example JSP Redirect Example Hibernate Session Tutorial Parsing XML String Using DOM Sort ArrayList Of Object Block Jboss Accessible Only From Localhost Tomcat Download fn:substringAfter() JSTL Function JSP Forward Example fn:length() JSTL Function Display Tag Library Tutorial Hibernate Mapping Example