Reading RSS using Informa API
21 April 2008RSS (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.
Related Posts:
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
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