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
Post a Comment