Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Read and Display RSS Feed in ASP.NET C#

Tags | MVC display RSS feed, display RSS feed in page, how to display RSS feed on page, display RSS feed on website, display RSS feed c#

  • Must read HTML Comment Box Code for Website
  • Send Email with Attachment in ASP.Net using C#

What is an RSS feed and how can I use it?

RSS stands for Rich Site Summary or somewhere known as Really Simple Syndication. It is a format for delivering regularly changing web content which is written in XML. There are many free RSS feed creator are available online like Google Feedburner, feedity etc. Using RSS you can easily publish regularly updated web content such as blogs, articles, and news etc.

Many news-related sites, weblogs, and other online publishers syndicate their content as an RSS feed to whoever wants it. Rss Feeds have following features:-

  • Allows you to syndicate your site content
  • RSS files can be automatically updated
  • Defines an easy way to share and view headlines and content
  • Allows personalized views for different sites

Display RSS feed in ASP.Net Page

In this article, we will explore many more about RSS feeds. In the context of displaying content of RSS feeds on your website, custom RSS feed, display RSS feeds from other sites, fetch and display RSS feeds, consuming RSS feed using, online RSS news aggregator with Refer the code below:-

    Display rss feed in page

How to Read and Display RSS Feed in ASP.NET C#


Feed Details

' target="_blank" class="btn btn-success">View Details
using System; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } void show() { FeedParser parser = new FeedParser(); if (drp_typ.SelectedItem.Value == "OTHER") { } else if (drp_typ.SelectedItem.Value == "RSS") { var items = parser.Parse(txt_url.Text, FeedType.RSS); Repeater1.DataSource = items; Repeater1.DataBind(); } } protected void Button2_Click(object sender, EventArgs e) { show(); } } using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Xml.Linq; using System.ServiceModel.Syndication; /// /// Summary description for FeedParser /// public class FeedParser { /// /// Parses the given and returns a . /// /// public IList Parse(string url, FeedType feedType) { return ParseRss(url); } /// /// Parses an RSS feed and returns a . /// public virtual IList ParseRss(string url) { try { XDocument doc = XDocument.Load(url); // RSS/Channel/item var entries = from item in doc.Root.Descendants().First(i => i.Name.LocalName == "channel").Elements().Where(i => i.Name.LocalName == "item") select new Item { FeedType = FeedType.RSS, Content = item.Elements().First(i => i.Name.LocalName == "description").Value, Link = item.Elements().First(i => i.Name.LocalName == "link").Value, PublishDate = ParseDate(item.Elements().First(i => i.Name.LocalName == "pubDate").Value), Title = item.Elements().First(i => i.Name.LocalName == "title").Value }; return entries.ToList(); } catch { return new List(); } } private DateTime ParseDate(string date) { DateTime result; if (DateTime.TryParse(date, out result)) return result; else return DateTime.MinValue; } } public enum FeedType { /// /// Really Simple Syndication format. /// RSS } public class Item { public string Link { get; set; } public string Title { get; set; } public string Content { get; set; } public DateTime PublishDate { get; set; } public FeedType FeedType { get; set; } public Item() { Link = string.Empty; Title = string.Empty; Content = string.Empty; PublishDate = DateTime.Today; FeedType = FeedType.RSS; } }

Display RSS feed on website – Demodisplay rss feed on website asp.netDownload Source Code

Did you find this post useful? I hope you liked this article. Please share with me your valuable suggestions and feedback.

The post How to Read and Display RSS Feed in ASP.NET C# appeared first on Dot Net Technology Tutorial, Dot Net Tricks and Tips, ASP.Net Tutorial C#.

This post first appeared on Asp Dot Net Tricks And Tips, Dot Net Coding Tips, Google Maps API Developer, please read the originial post: here

Share the post

How to Read and Display RSS Feed in ASP.NET C#


Subscribe to Asp Dot Net Tricks And Tips, Dot Net Coding Tips, Google Maps Api Developer

Get updates delivered right to your inbox!

Thank you for your subscription