Sunday, October 14, 2012

How to Read & Display Rss feed in asp.net website ?


In this article I am explaining how to read RSS feeds from website and display it on my Website using ASP.Net Namespaces :C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.ServiceModel.Syndication;
using System.Xml.Linq;
using System.Linq.Expressions;
using System.Xml;
GetRSS Function The GetRSS function is responsible to pull the RSS feed and display it on the web page. Refer the code below C#
private void GetRSS()
{
string rssUri = “http://www.just-drinks.com/mhusa/rssdata.aspx?feed=wine”;
var doc = System.Xml.Linq.XDocument.Load(rssUri);
var rssFeed = (from el in doc.Elements(“rss”).Elements(“channel”).Elements(“item”)
select new
{
Title = el.Element(“title”).Value,
Link = el.Element(“link”).Value,
Description = el.Element(“description”).Value
}).Take(20); // Take first 20 RSS Feed
lvFeed1.DataSource = rssFeed;
lvFeed1.DataBind();
}
Display the retrieved RSS Feeds To display the data I am using ASP.Net list view Control Refer below:





  • ” style=”color: Black;text-decoration: none; font-size: small”> <%#Eval(“Title”) %>
  • ” style=”text-decoration: none; color: Black”> <%#Eval(“Title”) %>
  • Good Day!!!!

    No comments:

    Post a Comment