Click here to Skip to main content
Licence CPOL
First Posted 18 Apr 2008
Views 11,545
Downloads 56
Bookmarked 18 times

Keyword Matching RSS Reader Control

By xbadenx | 18 Apr 2008
Display RSS results that contain specific keywords.

1
1 vote, 20.0%
2

3
4 votes, 80.0%
4

5
3.38/5 - 5 votes
μ 3.38, σa 1.57 [?]

Introduction

Using RSS feeds on web pages is a good way of creating dynamic content, which search engines love. The more your page changes, the more it gets crawled, and can affect your page rank.

However, just because you point your RSS reader to a feed, doesn't necessarily mean you'll get relevant content on that feed, a problem that is remedied by this control.

Background

This control came out of working on a similar control, RSS/XML Data-Binding to Data Control with Row Limitations.

Using the code

Using this control is quite simple. Simply place the code in your ~/Controls folder, drag it onto your .aspx page, and you're good to go. It does, however, require some configuration, usually in the PageLoad() method, either in the code-behind, or directly in your .aspx page.

Since we're interested in keyword matching, we provide the control with a list of keywords we would like to see in the RSS titles. Since one feed may not suffice, we can also provide a comma-delimited list of RSS sources (URLs) to retrieve content from.

RssReader1.SourceRss = 
            "http://news.google.com/news?hl=en&ned=us&" + 
            "amp;q=carbon+offset&ie=UTF-8&output=rss, http://news.go..."
RssReader1.TitleKeywords = "global warming,carbon footprint,global warming...
RssReader1.RowsToDisplay = 20;
RssReader1.Width = 300;
RssReader1.ShowLinks = true;
RssReader1.ShowTitles = true;
RssReader1.ShowDescriptions = false;
RssReader1.RowDivider = "";
RssReader1.UseTitleBullets = true;

Display

In the example above, we want to ensure that keywords such as {carbon footprint, biodeisel, global warming} exist... which, they do ;).

One great thing about this control is you could end up grabbing content and inserting RSS titles directly within paragraphs of your own content. This is achieved by setting ShowLinks=false, ShowTitles=true, ShowDescription=false. You would also probably want to limit the number of rows (RSS titles) to display down to one or two.

Displaying the contents of the control can be done in either a DataGrid or simple text, where you can display the results in a bulleted or non-bulleted format, configured through the UseTitleBullets parameter.

Title length

As in the example above, you may want to limit the length of the titles in order to fit in a given area. Setting the TitleLength parameter will truncate each title at the last word, adding " ..." at the end. What the control does not check for, however, is if any of your keywords exist in the non-truncated text. This is a simple thing to add if you really need to, but chances are that you don't want the titles to be too short, anyway.

Points of interest

Since you can provide an unlimited number of RSS source URLs, and the code has to scan through the content of each one, be vigilant of page load times - don't add too many URLs, as the delay will increase your page visitor's frustration, and possibly not even bother waiting for the page to load.

I've tested this with 15 URLs and a whole slew of keywords, and processing has been quite prompt.

History

None yet!

Don't forget to vote for this article!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

xbadenx

Systems Engineer

United States United States

Member
I have worked as a senior software engineer (C#) for over 10 years and currently serve as a technical architect for a global mobile software development company, guiding the development process for mobile applications for Android, BB, iPhone and iPad platforms.
 
I have worked for Nortel and IBM, and ran my own company which specializes in global mobile text messaging solutions.
 
Past tech flavors include C#, WCF, SOA, MVC, MVVM, Silverlight, Assembler, Pascal, VB, Java/J2EE/EJB/JDBC, Perl, TSQL, VisualAge, Websphere, TogetherSoft ControlCenter, Notes/Domino, and a whole lot of more capital letters put together that no one understands...

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionAdd feeds other than Google Pinmemberfab@fab-silva.com8:52 9 Apr '09  
Forgive the newbie question, but how do I get this reader to display feeds that come from sites other than Google? For example, I added "http://sports.espn.go.com/espn/rss/mlb/news" as my SourceRss and added "baseball" as the TitleKeywords. While I can see what I should be getting when I go to the ESPN site, my reader displays: Data Unavailable No data found.
 
Am I missing the proper query parameters? I've looked for this in the code but cannot find any requirements for this.
 
Any help would be appreciated.
GeneralWrap the lines in the PRE blocks. PinsitebuilderShog914:24 18 Apr '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120210.1 | Last Updated 18 Apr 2008
Article Copyright 2008 by xbadenx
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid