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); }
Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves a <see cref="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="RssFeed">RssFeed</see> object from the
        /// RSS feed's details.</returns>
        public static RSSFeed GetFeed(string Url, bool RdfFormat)
        {
            RSSReader rssReader = new RSSReader();

            rssReader.RdfMode = RdfFormat;
            return(rssReader.Retrieve(Url));
        }
Ejemplo n.º 2
0
        private bool UpdateItemCollection()
        {
            bool ret = false;

            foreach (string u in mUrlList)
            {
                RSSFeed f = RSSReader.GetFeed(u);
                if (string.IsNullOrEmpty(f.ErrorMessage))
                {
                    mItemCollection.RemoveAll(delegate(RSSItem o) { return(o.Feed.URL == u); });
                    foreach (RSSItem i in f.Items)
                    {
                        mItemCollection.Add(i);
                        ret = true;
                    }
                }
            }
            return(ret);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Retrieves a <see cref="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="RssFeed">RssFeed</see> object from the
 /// RSS feed's details.</returns>
 public static RSSFeed GetFeed(string Url)
 {
     RSSReader rssReader = new RSSReader();
     return rssReader.Retrieve(Url);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Retrieves a <see cref="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="RssFeed">RssFeed</see> object from the
 /// RSS feed's details.</returns>
 public static RSSFeed GetFeed(string Url,bool RdfFormat)
 {
     RSSReader rssReader = new RSSReader();
     rssReader.RdfMode = RdfFormat;
     return rssReader.Retrieve(Url);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Retrieves a <see cref="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="RssFeed">RssFeed</see> object from the
        /// RSS feed's details.</returns>
        public static RSSFeed GetFeed(string Url)
        {
            RSSReader rssReader = new RSSReader();

            return(rssReader.Retrieve(Url));
        }