Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 882
Tronics Avatar asked May 01 '12 14:05

Tronics


People also ask

How do I view an RSS feed?

Right click an empty space on the website you'd like an RSS feed for, then click View Page Source (the exact wording may vary depending on your browser). If searching for rss doesn't work, try atom instead. Look for an RSS URL, as you can see above, then copy it into your feed reader.

Does RSS use XML?

RSS is a Web content syndication format. Its name is an acronym for Really Simple Syndication. RSS is a dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.


3 Answers

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;
    ...                
}
like image 177
dlopezgonzalez Avatar answered Oct 19 '22 20:10

dlopezgonzalez


This is an old post, but to save people some time if you get here now like I did, I suggest you have a look at the CodeHollow.FeedReader package which supports a wider range of RSS versions, is easier to use and seems more robust. https://github.com/codehollow/FeedReader

like image 11
emilast Avatar answered Oct 19 '22 18:10

emilast


You're looking for the SyndicationFeed class, which does exactly that.

like image 9
SLaks Avatar answered Oct 19 '22 20:10

SLaks