Hi All,
I have news RssFeed URL,by using Rss Reader I am able to displaying all news articles of that News RssFeed URL.But my problems is I dont want display all news
articles, I want to display selected news articles based on keywords,I mean if news RssFeed consists of sports,education,entertainment,technology etc from that
keywords as sports,education, articles I want to display.
Thanks in advance.
Regards,
Mallepula
Reading RSS
public void readRSSDocument() throws Exception{
//Create the parser
RssParser parser = RssParserFactory.createDefault();
//Parse our url
Rss rss = parser.parse (
new URL("http://rss.cnn.com/rss/cnn_world.rss"));
}
ublic void readRSSDocument() throws Exception{
RssParser parser = RssParserFactory.createDefault();
Rss rss = parser.parse(
new URL("http://rss.cnn.com/rss/cnn_world.rss"));
//Get all XML elements in the feed
Here u can categoried
Collection items = rss.getChannel().getItems();
if(items != null && !items.isEmpty())
{
//Iterate over our main elements. Should have one for each article
for(Iterator i = items.iterator();
i.hasNext();
System.out.println())
{
Item item = (Item)i.next();
System.out.println("Title: " + item.getTitle());
System.out.println("Link: " + item.getLink());
System.out.println("Description: " + item.getDescription());
}
}
//Iterate over categories if we are provided with any
Collection categories = rss.getChannel().getCategories();
if(categories != null && !categories.isEmpty())
{
Category cat;
for(Iterator i = categories.iterator();
i.hasNext();
System.out.println("Category Domain: " + cat.getDomain()))
{
cat = (Category)i.next();
System.out.println("Category: " + cat);
}
}
}
Hope this will help if u r using rss reader.
Please let me know if any more information required
Post new comment