Click here to Skip to main content
Click here to Skip to main content
Go to top

RSS Consumer

, 12 May 2005
Rate this:
Please Sign up or sign in to vote.
Building an application to read RSS feeds.

Sample Image

Introduction

RSS Consumer is an RSS client that reads RSS feeds from any URL that points to an XML file over the web. It also allows the user to save any other non-RSS links. The user can arrange and organize his links by creating groups, that are saved in an XML file called the XMLFeedLibrary.xml, stored in a separate folder under the application folder.

The application is developed in .NET using C# and XML.

Background

An RSS feed is a regularly updated XML document that contains metadata about a news source and the content in it. Minimally, an RSS feed consists of a channel that represents the news source, which has a title, link, and description that describe the news source. Additionally, an RSS feed typically contains one or more item elements that represent individual news items, each of which should have a title, link, or description.

Note: The aforementioned elements appear in most RSS feeds but are not the only ones that can appear. Many RSS feeds also contain additional elements such as date or language. However, these elements and many others appear less commonly in practice.

There are many advanced RSS aggregators and clients available for free over the net. Requirements to develop an RSS aggregator is available at MSDN.

Using the RSS Consumer

To use the RSS Consumer, you need to first install the .NET framework on your machine. The interface is quite simple to use.

The application makes good use of the System.Xml library. The feeds are read by using the xmlDocument.Load() method of the xmlDocument object. The following code block explains how the RSS feeds are read and listed in the feed listview control. Once the links are listed, the user can browse each of the links by a single click.

public void FetchFeedInfo(string strFeedURL, string SearchNodeText)
{
    try
    {
        if(!SearchNodeText.Trim().Equals(""))
        {
            ClearFeedList();
            this.Cursor=Cursors.WaitCursor;
            XmlDocument xDoc=new XmlDocument();
            xDoc.Load(strFeedURL);
            //xDoc.Load("http://msdn.microsoft.com/rss.xml");
            //xDoc.Load("http://surya.somee.com/rss/rss.xml");
            XmlNodeList xnList= 
              xDoc.DocumentElement["channel"].SelectNodes(SearchNodeText);
            foreach(XmlNode xNode in xnList)
            {
                ListViewItem lstFeedItem=new ListViewItem();
                for(int i=0;i < xNode.ChildNodes.Count;i++)
                {
                    //lstFeedItem.Text=Convert.ToString(lstvFeed.Items.Count+1);
                    lstFeedItem.ImageIndex=0;
                    if(i==0)
                    {
                        lstFeedItem.SubItems.Add(xNode.ChildNodes[0].InnerText);
                        lstFeedItem.SubItems.Add("");
                        lstFeedItem.SubItems.Add("");
                        lstFeedItem.SubItems.Add("");
                    }
                    if(i==1)
                    {
                        lstFeedItem.SubItems.Add(
                          xNode.ChildNodes[1].InnerText.Substring(0,10));
                    }
                    if(i==2)
                    {
                        lstFeedItem.SubItems.Add(xNode.ChildNodes[2].InnerText);
                        lstFeedItem.Tag= xNode.ChildNodes[2].InnerText;
                    }
                }
                lstvFeed.Items.Add(lstFeedItem);
            }
            this.Cursor=Cursors.Default; 

            //navigate to the first item
            if(lstvFeed.Items.Count>0)
            {
                Object o=null;
                lstvFeed.Items[0].Selected=true;
                axWebBrowserFeed.Navigate(lstvFeed.SelectedItems[0].Tag.ToString(), 
                                                          ref o,ref o,ref o,ref o);
            }
         }
         else
         {
             //
         }
     }
     catch(Exception ex)
     {
         this.Cursor=Cursors.Default;
         MessageBox.Show(ex.Message + " : " + ex.StackTrace);
     }
}

License

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

Share

About the Author

B.Sai Suryanarayana
Team Leader
India India
A unique combination of management and innovative thinking coupled with good architecting and designing skills in the Information Technology industry
 
Around 9 years of overall work experience (5 years in Development, 3+ years in Project Management)
2 years experience in product development.
 
Managed complex projects through their lifecycle. Methodologies used include SDLC, Waterfall models.
 
Proven Expertise in Agile process implementation.
 
Estimation Techniques:
PERT, UCP and FPA
 
EXPERTISE: Architecture/Design;
Concept development; Systems Designing

RECENT ACHIEVEMENTS: As a Project Manager & Architect to Design, Develop and Deliver a Data-security tool for securing sensitive information in database.

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 12 May 2005
Article Copyright 2005 by B.Sai Suryanarayana
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid