A simple class that can be used to parse rss feed, Check the code attached it will display my twitter updates by parsing the rss feed using the class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Linq;
namespace RssFeed
{
//12-aug-2009 Priyan R
public class RssParser
{
public RssParser()
{
Items = new List<RssItem>();
}
public RssParser(string url):this()
{
URL = url;
}
#region Methods
public void Parse()
{
XDocument doc = XDocument.Load(URL, LoadOptions.None);
Items = (from t in doc.Descendants("item")
select new RssItem()
{
Title = t.Element("title").Value,
Description = t.Element("description").Value,
Link = t.Element("link").Value
}
).ToList();
}
#endregion
#region properties
public string URL { get; set; }
public List<RssItem> Items { get; set; }
#endregion
}
#region RSS Item Class
public class RssItem
{
public string Title{ get; set; }
public string Description { get; set; }
public string Link { get; set; }
}
#endregion
}