Best Way to read rss feed in .net Using C#

Tronics picture Tronics · May 1, 2012 · Viewed 134.3k times · Source

What is the best way to read RSS feeds?

I am using XmlTextReader to achieve this. Is there any other best way to do it?

XmlTextReader reader = new XmlTextReader(strURL);

DataSet ds = new DataSet();
ds.ReadXml(reader);

After reading the RSS feed using XmlTextReader, is there any way I can populate data to ListItem instead of DataSet?

enter image description here

Answer

dlopezgonzalez picture dlopezgonzalez · Jan 8, 2013

Add System.ServiceModel in references

Using SyndicationFeed:

string url = "http://fooblog.com/feed";
XmlReader reader = XmlReader.Create(url);
SyndicationFeed feed = SyndicationFeed.Load(reader);
reader.Close();
foreach (SyndicationItem item in feed.Items)
{
    String subject = item.Title.Text;    
    String summary = item.Summary.Text;
    ...                
}