Click here to Skip to main content
6,305,776 members and growing! (17,085 online)
Email Password   helpLost your password?
Web Development » Custom Controls » General     Intermediate License: The Code Project Open License (CPOL)

Keyword Matching RSS Reader Control

By xbadenx

Display RSS results that contain specific keywords.
C# (C# 1.0, C# 2.0, C# 3.0), XML, HTML, ASP.NET, Architect, Dev, Design
Posted:18 Apr 2008
Views:6,035
Bookmarked:11 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
5 votes for this article.
Popularity: 2.37 Rating: 3.38 out of 5

1
1 vote, 20.0%
2

3
4 votes, 80.0%
4

5

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


Member
I'm currently a senior software engineer (C#) for a major SEO/SEM company. In the past, I've worked for Nortel and IBM, and ran my own company which specializes in global mobile text messaging solutions.

Past tech flavors include Assembler, Pascal, VB, Java/J2EE/EJB/JDBC, Perl, TSQL, VisualAge, Websphere, TogetherSoft ControlCenter, Notes/Domino, C#, Visual Studio...

Occupation: Web Developer
Location: United States United States

Other popular Custom Controls articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 2 of 2 (Total in Forum: 2) (Refresh)FirstPrevNext
QuestionAdd feeds other than Google Pinmemberfab@fab-silva.com8:52 9 Apr '09  
GeneralWrap the lines in the PRE blocks. PinsitebuilderShog914:24 18 Apr '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 18 Apr 2008
Editor: Smitha Vijayan
Copyright 2008 by xbadenx
Everything else Copyright © CodeProject, 1999-2009
Web10 | Advertise on the Code Project