Click here to Skip to main content
15,868,440 members
Articles / Programming Languages / XML

RSS Reader

Rate me:
Please Sign up or sign in to vote.
4.80/5 (50 votes)
17 Feb 20044 min read 398.1K   17.5K   161  
An easy to use RSS feed reader
<?xml version="1.0"?>
<doc>
    <assembly>
        <name>RssReader</name>
    </assembly>
    <members>
        <member name="T:RssReaderApp.Form1">
            <summary>
            A quick application to test the RssReader class's functionality.
            </summary>
        </member>
        <member name="M:RssReaderApp.Form1.Dispose(System.Boolean)">
            <summary>
            Clean up any resources being used.
            </summary>
        </member>
        <member name="M:RssReaderApp.Form1.Main">
            <summary>
            The main entry point for the applications.
            </summary>
        </member>
        <member name="M:RssReaderApp.Form1.InitializeComponent">
            <summary>
            Required method for Designer support - do not modify
            the contents of this method with the code editor.
            </summary>
        </member>
        <member name="T:Sloppycode.net.RssReaderErrorEventArgs">
            <summary>
            Holds details about any errors that occured
            during the loading or parsing of the RSS feed.
            </summary>
        </member>
        <member name="P:Sloppycode.net.RssReaderErrorEventArgs.Message">
            <summary>
            The details of the error.
            </summary>
        </member>
        <member name="T:Sloppycode.net.RssReaderErrorEventHandler">
            <summary>
            Represents the method that will handle the RssReader error event.
            </summary>
        </member>
        <member name="T:Sloppycode.net.RssReader">
            <summary>
            The RssReader class provides a number of static methods for easy
            1 or 2 step retrieval of RSS feeds. RSS feeds can be downloaded from any
            URL, and are then parsed into an <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> data type,
            which contains properties representing most aspects of an RSS Feed. A number
            of events are available for the calling application to register at the various
            stages of the feed request and parsing.
            <example>
            The following example retrieves the RSS news feed for the BBC news website,
            and creates a HTML document from the feed's details. It saves the HTML document
            to disk, and launches the default browser with the document. The number of items
            displayed is limited to 5. If there is any error, a messagebox is displayed with
            the details of the error.
            <code>
            RssFeed feed = RssReader.GetFeed("http://www.bbc.co.uk/syndication/feeds/news/ukfs_news/front_page/rss091.xml");
            
            if ( feed.ErrorMessage == null || feed.ErrorMessage == "" )
            {
            	string template = "&lt;a href=\"%Link%&gt;%Title%&lt;/a&gt;&lt;br/&gt;%Description%&lt;br/&gt;&lt;br/&gt;&lt;ul&gt;%Items%&lt;/ul&gt;";
            	string itemTemplate = "&lt;li&gt;&lt;a href=\"%Link%&gt;%Title%&lt;/a&gt;&lt;br/&gt;%Description%&lt;/li&gt;";
            	string html = RssReader.CreateHtml(feed,template,itemTemplate,"",5);
            
            	StreamWriter streamWriter = File.CreateText("c:\\rss.html");
            	streamWriter.Write(html);
            	streamWriter.Close();
            
            	System.Diagnostics.Process.Start("c:\\rss.html");
            }
            else
            {
            	MessageBox.Show("Error getting feed:\r\n" +feed.ErrorMessage,"Rss Demo App",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
            }
            </code>
            </example>
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssReader.rootNodeName">
            <summary>
            Member for the public property.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssReader.channelNodeName">
            <summary>
            Member for the public property.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssReader.rdfMode">
            <summary>
            Member for the public property.
            </summary>
        </member>
        <member name="M:Sloppycode.net.RssReader.GetFeed(System.String,System.Boolean)">
            <summary>
            Retrieves a <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object using
            the url provided as the source of the Feed.
            </summary>
            <param name="Url">The url to retrieve the RSS feed from, this can
            be in the format of http:// and also file://.. (ftp?)</param>
            <param name="RdfFormat">If this is set to true, then the XML document
            is parsed slightly different, to cater sites with RDF feeds (such as
            slashdot.org and register.com). The whole RDF format is not supported,
            but those items in RSS which have a corresponding RDF property, such
            as description,title for the channel, and title,description for each
            item, are matched.</param>
            <returns>A <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object from the
            RSS feed's details.</returns>
        </member>
        <member name="M:Sloppycode.net.RssReader.GetFeed(System.String)">
            <summary>
            Retrieves a <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object using
            the url provided as the source of the Feed.
            </summary>
            <param name="Url">The url to retrieve the RSS feed from, this can
            be in the format of http:// and also file://.. (ftp?)</param>
            <returns>A <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object from the
            RSS feed's details.</returns>
        </member>
        <member name="M:Sloppycode.net.RssReader.CreateHtml(Sloppycode.net.RssFeed,System.String,System.String,System.String)">
            <summary>
            A simplified method of creating a HTML (or any document) from an
            RSS Feed. See <see cref="T:Sloppycode.net.RssHtmlMaker">RssHtmlMaker</see>
            </summary>
            <param name="Feed">The <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object to
            get the tokens' data from.</param>
            <param name="Template">The overall HTML template (or any other format)
            to replace the tokens in.</param>
            <param name="ItemPrefix">A string template that is prepended to the beginning
            of each RSS item.</param>
            <param name="ItemSuffix">A string template that is apppended to the end
            of each RSS item.</param>
            <returns>A string with the templates provided parsed of their tokens, with
            the data values in their place.</returns>
        </member>
        <member name="M:Sloppycode.net.RssReader.CreateHtml(Sloppycode.net.RssFeed,System.String,System.String,System.String,System.Int32)">
            <summary>
            A simplified method of creating a HTML (or any document) from an
            RSS Feed. See <see cref="T:Sloppycode.net.RssHtmlMaker">RssHtmlMaker</see>
            </summary>
            <param name="Feed">The <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object to
            get the tokens' data from.</param>
            <param name="Template">The overall HTML template (or any other format)
            to replace the tokens in.</param>
            <param name="ItemPrefix">A string template that is prepended to the beginning
            of each RSS item.</param>
            <param name="ItemSuffix">A string template that is apppended to the end
            of each RSS item.</param>
            <param name="MaxItems">The maximum number of RSS items to display.</param>
            <returns>A string with the templates provided parsed of their tokens, with
            the data values in their place.</returns>
        </member>
        <member name="M:Sloppycode.net.RssReader.Retrieve(System.String)">
            <summary>
            Retrieves an RSS feed using the given Url, parses it and
            creates and new <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object with the information.
            If an error occurs in the XML loading of the document, or parsing of
            the RSS feed, the error is trapped and stored inside the RssFeed's
            ErrorMessage property.
            </summary>
            <param name="Url">The url to retrieve the RSS feed from, this can
            be in the format of http:// and also file://.. (ftp?)</param>
            <returns>An <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object with information
            retrieved from the feed.</returns>
        </member>
        <member name="M:Sloppycode.net.RssReader.getRssItem(System.Xml.XmlNode)">
            <summary>
            Creates an RSS item from an XML node with the 
            corresponding child nodes (title,description etc.)
            </summary>
            <param name="xmlNode">The node to extract the details from</param>
            <returns>An RssItem object with details taken from the item node.</returns>
        </member>
        <member name="E:Sloppycode.net.RssReader.FeedLoaded">
            <summary>
            This event is fired when the feed has finished loading from the URL
            provided, into the XML parser.
            </summary>
        </member>
        <member name="E:Sloppycode.net.RssReader.RssNodeFound">
            <summary>
            This event is fired when the root node (typically 'rss') has
            been found in the feed.
            </summary>
        </member>
        <member name="E:Sloppycode.net.RssReader.ChannelNodeFound">
            <summary>
            This event is fired when the channel/child node of the rss node
            (typically 'channel') has been found in the feed.
            </summary>
        </member>
        <member name="E:Sloppycode.net.RssReader.ItemAdded">
            <summary>
            This event is fired when an item is added to the <see cref="T:Sloppycode.net.RssFeed">RssFeed</see>'s
            collection of items.
            </summary>
        </member>
        <member name="E:Sloppycode.net.RssReader.Error">
            <summary>
            This event is fired when an error occurs in the loading or parsing
            of the feed. The same error message is also available in the ErrorMessage
            property of the <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object that is returned
            by the <see cref="M:Sloppycode.net.RssReader.Retrieve(System.String)">Retrieve</see> method.
            </summary>
        </member>
        <member name="P:Sloppycode.net.RssReader.RootNodeName">
            <summary>
            The node name for the channel element
            in the RSS feed. This will rarely ever to be
            changed. Default is 'channel'.
            </summary>
        </member>
        <member name="P:Sloppycode.net.RssReader.ChannelNodeName">
            <summary>
            The node name for the root rss element
            in the RSS feed. This is altered automatically to 'rdf:RDF'
            when RdfMode is set to true. Default is 'rss'.
            </summary>
        </member>
        <member name="P:Sloppycode.net.RssReader.RdfMode">
            <summary>
            If this is set to true, then the XML document
            is parsed slightly different, to cater sites with RDF feeds (such as
            slashdot.org and register.com). The whole RDF format is not supported,
            but those items in RSS which have a corresponding RDF property, such
            as description,title for the channel, and title,description for each
            item, are matched.
            </summary>
        </member>
        <member name="T:Sloppycode.net.RssHtmlMaker">
            <summary>
            This class provides an easy method of converting a <see cref="T:Sloppycode.net.RssFeed">RssFeed</see>
            object into a simple HTML document. This document can then be written to
            file, where it can be stored in a cached state (saving a feed request each
            time the feed is required). 
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssHtmlMaker.maxItems">
            <summary>
            Member for the public property.
            </summary>
        </member>
        <member name="M:Sloppycode.net.RssHtmlMaker.GetHtmlContents(Sloppycode.net.RssFeed,System.String,System.String,System.String)">
            <summary>
            Creates a HTML document, or any format - this is only limited by
            the template you provide - from the provided
            <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object. The tokens described in the
            remarks section are replaced with their values inside the template.
            The items in the RSS feed are replaced using the ItemPrefix and ItemSuffix
            templates, where the suffix is placed face, and the suffix is appended on the end.
            </summary>
            <remarks>
            The following are a list of tokens which are replaced inside the main Template,
            with their corresponding values from the provided <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> 
            object. For details on each token, see its corresponding property in the 
            <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object.
            <list type="bullet">
            <item>%Title%</item>
            <item>%Description%</item>
            <item>%Link%</item>
            <item>%Language%</item>
            <item>%Copyright%</item>
            <item>%Webmaster%</item>
            <item>%PubDate%</item>
            <item>%LastBuildDate%</item>
            <item>%Category%</item>
            <item>%Generator%</item>
            <item>%Ttl%</item>
            <item>%Rating%</item>
            <item>%Skiphours%</item>
            <item>%Skipdays%</item>
            <item>%Skipdays%</item>
            <item>%Items% - This is replaced by the parsed template of the items</item>
            </list>
            The following are a list of tokens which are replaced inside the ItemPrefix
            and ItemSuffix templates, with their corresponding values from the 
            provided <see cref="T:Sloppycode.net.RssItem">RssItem</see> object. For details
            on each token, see its corresponding property in 
            the <see cref="T:Sloppycode.net.RssItem">RssItem</see> object.
            <list type="bullet">
            <item>%Title%</item>
            <item>%Description%</item>
            <item>%Link%</item>
            <item>%Author%</item>
            <item>%Comments%</item>
            <item>%Pubdate%</item>
            <item>%Guid%</item>
            </list>
            </remarks>
            <param name="Feed">The <see cref="T:Sloppycode.net.RssFeed">RssFeed</see> object to
            get the tokens' data from.</param>
            <param name="Template">The overall HTML template (or any other format)
            to replace the tokens in.</param>
            <param name="ItemPrefix">A string template that is prepended to the beginning
            of each RSS item.</param>
            <param name="ItemSuffix">A string template that is apppended to the end
            of each RSS item.</param>
            <returns>A string with the templates provided parsed of their tokens, with
            the data values in their place.</returns>
        </member>
        <member name="P:Sloppycode.net.RssHtmlMaker.MaxItems">
            <summary>
            Restricts the number of items that are displayed and replaced
            using the %Items% token in the HTML template.
            </summary>
        </member>
        <member name="T:Sloppycode.net.RssFeed">
            <summary>
            A data type to represent all properties of single RSS feed.
            (one XML document). The descriptions for
            the properties of RssItem are para-phrased from the 
            <see href="http://blogs.law.harvard.edu/tech/rss">RSS 2 specification</see>.
            See <see cref="T:Sloppycode.net.RssReader">RssReader</see> for properties which 
            have not yet been implemented in this version of the
            the RssReader class.
            </summary>
            <remarks>
            The following elements of the RSS &lt;channel&gt; node aren't
            supported by this version of RssReader:
            <list type="bullet">
            <item>image (has subelements: image,url,title,link)</item>
            <item>cloud (has attributes: domain,port,path,registerProcedure,protocol)</item>
            <item>textInput (has subelements: title,description,name,link)</item>
            </list>
            </remarks>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Title">
            <summary>
            The name of the channel.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Description">
            <summary>
            Phrase or sentence describing the channel.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Link">
            <summary>
            The URL to the HTML website corresponding to the channel.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Language">
            <summary>
            The language the channel is written in. This allows 
            aggregators to group all Italian language sites, for example, on a single page. 
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Copyright">
            <summary>
            Copyright notice for content in the channel.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Webmaster">
            <summary>
            Email address for person responsible for technical issues relating to channel.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.PubDate">
            <summary>
            The publication date for the content in the channel. 
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.LastBuildDate">
            <summary>
            The last time the content of the channel changed.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Category">
            <summary>
            Specify one or more categories that the channel belongs to.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Generator">
            <summary>
            A string indicating the program used to generate the channel.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Ttl">
            <summary>
            ttl stands for time to live. It's a number of minutes 
            that indicates how long a channel can be cached before 
            refreshing from the source
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Rating">
            <summary>
            The <see href="http://www.w3.org/PICS/">PICS</see> rating for the channel.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Skiphours">
            <summary>
            A hint for aggregators telling them which hours they can skip. 
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Skipdays">
            <summary>
            A hint for aggregators telling them which days they can skip. 
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.ManagingEditor">
            <summary>
            Email address for person responsible for editorial content.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.Items">
            <summary>
            A collection of RssItem datatypes, representing each
            item for the RSS feed.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssFeed.ErrorMessage">
            <summary>
            Contains any errors that occured during the loading or
            parsing of the XML document. Compare this to a blank string
            to see if any errors occured.
            </summary>
        </member>
        <!-- Badly formed XML comment ignored for member "T:Sloppycode.net.RssItem" -->
        <member name="F:Sloppycode.net.RssItem.Title">
            <summary>
            The title of the item.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssItem.Description">
            <summary>
            The item synopsis.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssItem.Link">
            <summary>
            The URL of the item.
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssItem.Author">
            <summary>
            Email address of the author of the item. 
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssItem.Comments">
            <summary>
            URL of a page for comments relating to the item
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssItem.Pubdate">
            <summary>
            Indicates when the item was published. 
            </summary>
        </member>
        <member name="F:Sloppycode.net.RssItem.Guid">
            <summary>
            A string that uniquely identifies the item.
            </summary>
        </member>
        <member name="T:Sloppycode.net.RssItems">
            <summary>
            Represents a collection of RSS items for
            the RSS feed.
            </summary>
        </member>
    </members>
</doc>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Web Developer
United Kingdom United Kingdom
London based C# programmer.

I maintain my own pet C# site http://www.sloppycode.net in my spare time.

Comments and Discussions