Click here to Skip to main content
Click here to Skip to main content

Keyword Matching RSS Reader Control

By , 18 Apr 2008
 

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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionAdd feeds other than Googlememberfab@fab-silva.com9 Apr '09 - 7:52 
GeneralWrap the lines in the PRE blocks.sitebuilderShog918 Apr '08 - 13:24 

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

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