Click here to Skip to main content
11,804,574 members (79,323 online)
Click here to Skip to main content

RSS Feed Link Reader

, 29 Feb 2008 CPOL 50.3K 840 50
Rate this:
Please Sign up or sign in to vote.
Constructing a simple application that may be used to view RSS feeds from the desktop


This article discusses the construction of a simple application that may be used to view RSS feeds from the desktop. The application allows the user to select a canned RSS feed or to key one. The RSS feed is opened and the article title and link nodes from the feed are placed into a tree view control. Each title becomes the parent of the related link.


Figure 1: Application in Use

The title of the article occupies the parent node with the link node placed as the child of each title node. If the user clicks on any of the link nodes, the article associated with the title will be opened into a web browser control.


Figure 2: Canned RSS Feeds in Drop-down, Current RSS Feed on Left Side

The intent of the application was to provide a simple tool that may be used to organize and read RSS postings. The titles and links are recovered from the XML returned from the RSS service.

Getting Started

In order to get started, unzip the included project and open the solution in the Visual Studio 2008 environment. In the solution explorer, you should note these files:


Figure 3: Solution Explorer

As you can see, the project is a Windows Forms application containing only a single form. The form itself contains a tool strip control docked to the top with a text box used for entering RSS feed locations, a button control to open the RSS feed, and a combo box containing a collection of RSS feed which may be directly opened. The left-hand side of the form contains a TreeView control used to display the RSS feed titles and links. The right-hand side contains a web browser control that is used to display the linked page.

The Main Form (frmRss.cs)

The main form is used to open the selected RSS feed as an XML document and to display them in TreeView format. The form also places the story link as a child node to each title node. If you’d care to open the code view up, in the IDE you will see that the code file begins as follows:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;

Note that the additions of the System.Xml and System.Xml.XPath libraries are the only actual departure from the default. Following the imports, a class is defined and a constructor added. A local string variable is declared and used to hold the RSS feed URL. Within the constructor, the string variable used to point to the location of the RSS feed is zeroized as an empty string.

namespace RSSFeedSpeedReader
    public partial class frmRss : Form
        // the current path to an RSS feed
        string mRssUrl;

        /// <span class="code-SummaryComment"><summary></span>
        /// Constructor
        /// <span class="code-SummaryComment"></summary></span>
        public frmRss()

            // zeroize rss feed line
            mRssUrl = string.Empty;

Next up is the click event handler for the RSS Go button located on the form’s tool strip control. Within this click event handler, the code is placed to query for only the RSS feed item title and link. These two values are loaded into the tree view. They make it possible for the user to read the article title and then open the link into the web browser control to read it if they are interested in getting more information on the topic. This section of code in annotated and should be easy enough to follow using the comments:

/// <span class="code-SummaryComment"><summary></span>
/// Open up an RSS Feed into the treeview control
/// <span class="code-SummaryComment"></summary></span>
/// <span class="code-SummaryComment"><param name="sender"></param></span>
/// <span class="code-SummaryComment"><param name="e"></param></span>
private void tsRssGo_Click(object sender, EventArgs e)

        // set the file path member var
        mRssUrl = this.tsRssLocation.Text;

        // Clear the treeview.

        // set the wait cursor
        this.Cursor = Cursors.WaitCursor;

        // create a new xml doc
        XmlDocument doc = new XmlDocument();

            // load the xml doc

            // return the cursor
            this.Cursor = Cursors.Default;
        catch (Exception ex1)
            // return the cursor
            this.Cursor = Cursors.Default;

            // tell a story

        // get an xpath navigator   
        XPathNavigator navigator = doc.CreateNavigator();

            // look for the path to the rss item titles; navigate
            // through the nodes to get all titles
            XPathNodeIterator nodes =
            while (nodes.MoveNext())
                // clean up the text for display
                XPathNavigator node = nodes.Current;
                string tmp = node.Value.Trim();
                tmp = tmp.Replace("\n", "");
                tmp = tmp.Replace("\r", "");

                // add a new treeview node for this
                // news item title

            // set a position counter
            int position = 0;

            // Get the links from the RSS feed
            XPathNodeIterator nodesLink =
            while (nodesLink.MoveNext())
                // clean up the link
                XPathNavigator node = nodesLink.Current;
                string tmp = node.Value.Trim();
                tmp = tmp.Replace("\n", "");
                tmp = tmp.Replace("\r", "");

                // use the position counter
                // to add a link child node
                // to each news item title

                // increment the position counter
        catch (Exception ex)
            MessageBox.Show(ex.Message, "RSS Feed Load Error");

        // restore the cursor
        this.Cursor = Cursors.Default;

    catch (Exception ex2)
        // snitch
        MessageBox.Show(ex2.ToString(), "RSS Feed Initialization

The next section of the code is used to load the link content into the web browser control. This is accomplished using the After Select event from the TreeView control. When this event fires, the code merely examines the link text and, if it starts with http, the function makes an attempt to load the link into the web browser control occupying the right hand panel in the main form.

/// <span class="code-SummaryComment"><summary></span>
/// Use the after select event to open the link
/// into the web browser control
/// <span class="code-SummaryComment"></summary></span>
/// <span class="code-SummaryComment"><param name="sender"></param></span>
/// <span class="code-SummaryComment"><param name="e"></param></span>
private void tvwRss_AfterSelect(object sender, TreeViewEventArgs e)
        // get the first four characters from the link
        string tmp = tvwRss.SelectedNode.Text.Substring(0, 4);

        // test the link text and then
        // navigate the browser to that link
        if (tmp == "http")
        // if it is not a link, skip it

The last method in the class is the handler for the canned feeds combo box selected index changed event. In this code, when the user selects a canned feed from the drop down list, that link is loaded into the tool strip’s RSS Location text box control and the tool strip control’s RSS Go button’s click event is fired. That button click event handler will clear the tree view control and reload it with the information captured from the replacement RSS feed.

/// <span class="code-SummaryComment"><summary></span>
/// If the user selects a canned RSS feed from the drop down,
/// load the text into the toolstrip RSS location text box and
/// then use the tsRssGo_Click event to launch the
/// page into the browser
/// <span class="code-SummaryComment"></summary></span>
/// <span class="code-SummaryComment"><param name="sender"></param></span>
/// <span class="code-SummaryComment"><param name="e"></param></span>
private void tsCboFeeds_SelectedIndexChanged(object sender, EventArgs
    tsRssLocation.Text = tsCboFeeds.SelectedItem.ToString();
    tsRssGo_Click(this, new EventArgs());


This application demonstrates a simple way of building an RSS Feed reader through the manipulation of the RSS Feed’s XML. This is a little different than most of the RSS Feeder readers I have encountered in that it does not attempt to provide the standard set of information returned from the feed in a ListBox or similar control. Rather, this approach only displays the headlines and provides the links to the main story using the tree view control and a web browser control, in that the user can scan the headlines and then pop open the link directly to display the main story in a web browser control. Of course, you can pull additional information from the feed and display it using other added controls. The approach is certainly something that can be expanded upon. However, this does provide a clean and simple interface to the RSS Feed's main points of information.


  • 29 February, 2008 -- Original version posted


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


About the Author

Software Developer (Senior)
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionMy Vote of 4 Pin
Yukiiii1-Oct-11 9:18
memberYukiiii1-Oct-11 9:18 
Generalparser to html Pin
trungysp198626-Oct-08 23:20
membertrungysp198626-Oct-08 23:20 
GeneralGood job Pin
VCKicks1-Sep-08 11:19
memberVCKicks1-Sep-08 11:19 
QuestionVS2005 help Pin
flehns21-Apr-08 19:02
memberflehns21-Apr-08 19:02 
GeneralSplit UI and logic Pin
MaxGuernsey4-Mar-08 2:31
memberMaxGuernsey4-Mar-08 2:31 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151002.1 | Last Updated 29 Feb 2008
Article Copyright 2008 by salysle
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid