[.NET]Read RSS by C#

I searched around the net for a C# rss reader, but samples are either too complicated or errors prone. DataSet.ReadXml() gets a bug...So, finnaly I realized that write one of my own rss reader would be a quick and better than use one from the internet. And I think this one is the BEST:)No more words on this topic, code speak louder.

class Program
{
    static List<RssFeedItem> rssFeedItems = new 
List
<RssFeedItem>();     static RssFeedItem rssItem;     static void Main(string[] args)     {         Console.WriteLine("good");         ReadRssXML(@"http://xhinker.com/syndication.axd");         Console.ReadLine();     }     static void ReadRssXML(string url)     {         WebClient wc=new WebClient();         wc.OpenReadCompleted += 
new
 OpenReadCompletedEventHandler(wc_OpenReadCompleted);         wc.OpenReadAsync(new Uri(url));     }     static void wc_OpenReadCompleted(object sender, 
OpenReadCompletedEventArgs
 e)     {        XmlDocument xmlDoc = new XmlDocument();        xmlDoc.Load(e.Result);         XmlNodeList itemsNodes = xmlDoc.SelectNodes("//rss/channel/item");         foreach (XmlNode itemNode in itemsNodes)         {             rssItem = new RssFeedItem();             rssItem.RssTitle =
itemNode.SelectSingleNode("title").InnerText;            rssItem.Description =
itemNode.SelectSingleNode("description").InnerText;             rssFeedItems.Add(rssItem);         }         Console.WriteLine(rssFeedItems.Count);     } }  public class RssFeedItem  {     public string RssTitle { getset; }     public string Description { getset; }     public string Link { getset; }     public int ItemId { getset; }     public DateTime PublishDate { getset; }     public int ChannelId { getset; }  }

 

 

blog comments powered by Disqus