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
?
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.
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.
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;
...
}
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
You're looking for the SyndicationFeed
class, which does exactly that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With