Reading RSS using Informa API

21 April 2008

RSS (Really Simple Syndication) is a family of Web feed formats used to publish frequently updated content such as blog entries, news headlines, and podcasts. It is actually a specification for XML files to provide syndicated data.

To read RSS feeds in a Java application is easy. You have to use Informa API which is availabel at:
http://informa.sourceforge.net/.

The code snippet given below shows how to read RSS using Informa API.

try {      
  URL feed = new URL("file:/C:/samplefeed.rss");
  ChannelFormat format = FormatDetector.getFormat(feed);
  ChannelParserCollection parsers = 
                          ChannelParserCollection.getInstance();
 
  ChannelParserIF parser = 
    parsers.getParser(format, feed);
 
  parser.setBuilder(new ChannelBuilder());
  ChannelIF channel = parser.parse();
 
  for (Iterator iter = channel.getItems().iterator(); 
                                     iter.hasNext();) {
    ItemIF item = (ItemIF)iter.next();
    System.out.println(item.getTitle());
  }
} catch (MalformedURLException mue) {
  mue.printStackTrace();
} catch (UnsupportedFormatException ufe) {
  ufe.printStackTrace();
} catch (ParseException pe) {
  pe.printStackTrace();
}

This given example gets the RSS feed and prints out the news items on the console.

del.icio.us:Reading RSS using Informa API  digg:Reading RSS using Informa API  spurl:Reading RSS using Informa API  wists:Reading RSS using Informa API  simpy:Reading RSS using Informa API  newsvine:Reading RSS using Informa API  blinklist:Reading RSS using Informa API  furl:Reading RSS using Informa API  reddit:Reading RSS using Informa API  fark:Reading RSS using Informa API  blogmarks:Reading RSS using Informa API  Y!:Reading RSS using Informa API  smarking:Reading RSS using Informa API  magnolia:Reading RSS using Informa API  segnalo:Reading RSS using Informa API  gifttagging:Reading RSS using Informa API

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Reading RSS using Informa API

One Response to “Reading RSS using Informa API”

  1. Sunny Says:

    Hi,

    Please see the following code which I am trying with informa API and suggest me how can I get image separately which as if for now according to this code is coming with in a description. its just a test code… I will really appreciate for your suggestions.

    Channel:
    Description:
    PubDate:
    PubDate:

    TitleTreaserCategoriesDateLink

Leave a Reply