Rome is a very simple Java API for reading RSS Feeds and is available under Apache License 2.0
Rome Home Page
https://rome.dev.java.net/
If you are a maven user just add this dependency
<dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
<version>1.0RC2</version>
</dependency>
if you are using ant
1. Add Rome jar from https://rome.dev.java.net/dist/rome-1.0.jar
2. Add JDOM jar from http://www.jdom.org/dist/binary/archive/jdom-1.0.zip
And here is the code to pull feeds,
import java.net.URL;
import java.util.List;
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 App {
public static void main(String[] args) throws Exception {
String url = "http://rss.cnn.com/rss/cnn_topstories.rss";
URL feedUrl = new URL(url);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
for (SyndEntry entry : (List<SyndEntry>)feed.getEntries()) {
System.out.println(entry.getTitle());
}
}
}
Checkout SyndEntry API doc
It was that simple just instantiating SyndFeedInput and SyndFeed
Rome Home Page
https://rome.dev.java.net/
If you are a maven user just add this dependency
<dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
<version>1.0RC2</version>
</dependency>
if you are using ant
1. Add Rome jar from https://rome.dev.java.net/dist/rome-1.0.jar
2. Add JDOM jar from http://www.jdom.org/dist/binary/archive/jdom-1.0.zip
And here is the code to pull feeds,
import java.net.URL;
import java.util.List;
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 App {
public static void main(String[] args) throws Exception {
String url = "http://rss.cnn.com/rss/cnn_topstories.rss";
URL feedUrl = new URL(url);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
for (SyndEntry entry : (List<SyndEntry>)feed.getEntries()) {
System.out.println(entry.getTitle());
}
}
}
Checkout SyndEntry API doc
It was that simple just instantiating SyndFeedInput and SyndFeed
Comments