Frage

I am trying to read RSS feed in java I am using ROME to read the feed, but getting an error cannot access org.jdom.Document class file for org.jdom.Document not found SyndFeed feed = new SyndFeedInput().build(reader); 1 error

I have added the jdom to the lib but still am getting the error. kindly guide me how to solve it. my code is as follows

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("http://viralpatel.net/blogs/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();
    }
  }
}
War es hilfreich?

Lösung

Which version of JDOM did you use? It seems to me that ROME doesn't work with the newest version, 2.0.0, but requires the older version 1. Download the JDOM jar from here.

Andere Tipps

I would recommend to go through this web page , here you will find the working code to read and create RSS Feeds

http://www.vogella.com/articles/RSSFeed/article.html

courtesy :-vogella.com

He does not uses the Rome for fetching the RSS Feeds but uses the set of custom built classes that help in creating and fetching the RSS feeds from the Web server

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top