Simsons
Simsons

Reputation: 12745

How do I consume a RSS feed in ASP.Net webapp

I need to create a web app which will consume RSS feed. Do I need to go in the same way as ,

Create a XMLReader , Load XML , Parse it , then Bind the values to different fields. Is there any other way to consume the web RSS feed and display it on my aspx page.

Upvotes: 1

Views: 2711

Answers (3)

William
William

Reputation: 8067

I've written a blog post on this which will step you through the process.

http://www.wduffy.co.uk/blog/how-to-consume-an-xml-feed-in-aspnet-rss/

Upvotes: 1

ColinE
ColinE

Reputation: 70160

The steps you describe are pretty much what you have to do, load the XML, parse it, then render the output. However, there are some APIs that make it pretty easy to achieve this task. For example Linq-to-XML makes parsing an RSS feed almost trivial. For example, this code parses and RSS feed, creating a FeedItemModel for each item:

var rssFeed = XDocument.Parse(yourRSSString);
var items = from item in rssFeed.Descendants("item")
            select new FeedItemModel()
                    {
                        Title = item.Element("title").Value,
                        DatePublished = DateTime.Parse(item.Element("pubDate").Value),
                        Url = item.Element("link").Value,
                        Description = item.Element("description").Value
                    };

Upvotes: 2

user536158
user536158

Reputation:

There is an RSS toolkit available on line. you can try using it if you want.

Upvotes: 0

Related Questions