Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

RE:Rss--Search Engine For Rss Feeds.


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

Your rating: None Average: 2 (1 vote)

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <p> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br /> <br> <strike>
  • Lines and paragraphs break automatically.
  • Use <!--pagebreak--> to create page breaks.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
Just checking to see if you're an actual person rather than a spammer. Sorry for the inconvenience.