How to display RSS FEED of other website to my site in asp.net?

 This method used to get RSS feed details and load into gridview
 
private void PopulateRssFeed()
{
    string rssFeedUrl = ConfigurationManager.AppSettings["RssFeedUrl"];
    List<feeds> feeds = new List<feeds>();
    XDocument xDoc = XDocument.Load(rssFeedUrl);
    var items = (from x in xDoc.Descendants("item")
                 select new
                     {
                         title = x.Element("title").Value,
                         link = x.Element("link").Value,
                         pubDate = x.Element("pubDate").Value,
                         description = x.Element("description").Value
                     });
    if (items != null)
    {
        feeds.AddRange(items.Select(i => new Feeds
            {
                Title = i.title, Link = i.link, PublishDate = i.pubDate, Description = i.description
            }));
    }
    gvRss.DataSource = feeds;
    gvRss.DataBind();
}

Comments

Popular posts from this blog

.NET Design Patterns Tutorial - MVC, MVP and MVVM Design Patterns

C# Coding Standards and Naming Conventions

What is the difference between C and C++?