C# Class ZForge.Controls.RSS.RSSReader

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 RssFeed 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. 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. 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 = "<a href=\"%Link%>%Title%</a><br/>%Description%<br/><br/><ul>%Items%</ul>"; string itemTemplate = "<li><a href=\"%Link%>%Title%</a><br/>%Description%</li>"; 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); }
Mostrar archivo Open project: zhuangyy/Motion Class Usage Examples

Public Methods

Method Description
GetFeed ( string Url ) : RSSFeed

Retrieves a RssFeed object using the url provided as the source of the Feed.

GetFeed ( string Url, bool RdfFormat ) : RSSFeed

Retrieves a RssFeed object using the url provided as the source of the Feed.

Retrieve ( string Url ) : RSSFeed

Retrieves an RSS feed using the given Url, parses it and creates and new RssFeed 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.

Private Methods

Method Description
getRssItem ( XmlNode xmlNode ) : RSSItem

Creates an RSS item from an XML node with the corresponding child nodes (title,description etc.)

Method Details

GetFeed() public static method

Retrieves a RssFeed object using the url provided as the source of the Feed.
public static GetFeed ( string Url ) : RSSFeed
Url string The url to retrieve the RSS feed from, this can /// be in the format of http:// and also file://.. (ftp?)
return RSSFeed

GetFeed() public static method

Retrieves a RssFeed object using the url provided as the source of the Feed.
public static GetFeed ( string Url, bool RdfFormat ) : RSSFeed
Url string The url to retrieve the RSS feed from, this can /// be in the format of http:// and also file://.. (ftp?)
RdfFormat bool 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.
return RSSFeed

Retrieve() public method

Retrieves an RSS feed using the given Url, parses it and creates and new RssFeed 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.
public Retrieve ( string Url ) : RSSFeed
Url string The url to retrieve the RSS feed from, this can /// be in the format of http:// and also file://.. (ftp?)
return RSSFeed