Home > DeveloperSection > Blogs > Creating RSS feed for website

Creating RSS feed for website

C# C# 
0 Comment(s)
 917  View(s)
Rate this:

Creating RSS feed for website

RSS stands for Really Simple Syndication or it's sometimes referred to as Rich Site Summary.  It's an XML-based content format for distributing news, headlines, content, etc.

Most popular sites news sites and blogs provide RSS feeds for you to subscribe to. All you need is a feed reader to view its contents. You can also create feeds for your own website so your audience can subscribe to them. If you update your content frequently and promote the feed effectively, it can help drive more steady traffic to your website.

There is some specific format from which you can create RSS feed. Let’s take a simple example, how to create RSS feeds for website.

Here I’m just creating a dynamic RSS page for Articles, Blogs and Forums etc. With the help of this a user can bookmark either article sections, blogs section or forums sections.

To create a RSS feeds you start off the RSS file as follows:

<xml version="1.0" encoding="utf-8">

<rss version="2.0">


The first two lines specify the XML and RSS version as you can see. The third line opens a ‘channel’ tag. This is what would contain all the information for your channel or website.  Add these three lines as they are.

<title>MindStick Software Pvt Ltd.</title>


<description>MindStick Software Pvt Ltd.</description>


Code of RSS.aspx Page:

<%@ Page Language="C#" ContentType="text/xml" AutoEventWireup="true" CodeFile="RSS.aspx.cs"

Inherits="LatestArticle_RSS" %>

<asp:repeater id="Repeater1" runat="server">


<rss version="2.0">


<title>MindStick Software Pvt Ltd.</title>


<description>Unleash Your Imagination...</description>



<title>MindStick Software Pvt Ltd.</title>


<description>MindStick Software Pvt Ltd.</description>







<title><%# Server.UrlDecode(RemoveIllegalCharacters(DataBinder.Eval(Container.DataItem, "Title"))) %></title>

<link>http://www.mindstick.com/Articles/<%# DataBinder.Eval(Container.DataItem, "ArticleID") %></link>

<author><%# RemoveIllegalCharacters(DataBinder.Eval(Container.DataItem, "CreatedBy"))%></author>

<pubDate><%# String.Format("{0:R}", DataBinder.Eval(Container.DataItem, "CreationDate"))%></pubDate>




</channel> </rss>



Code of RSS.aspx.cs Page:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data.SqlClient;

using System.Data;

using System.Configuration;

public partial class LatestArticle_RSS : System.Web.UI.Page


    protected void Page_Load(object sender, EventArgs e)


        SqlConnection sqlConn = new SqlConnection(“Your connection String”);


        SqlCommand cmd = new SqlCommand("Write here your command for selecting data from database");

            cmd.Connection = sqlConn;

          Repeater1.DataSource = cmd.ExecuteReader();




  protected string RemoveIllegalCharacters(object input)


        // cast the input to a string 

        string data = input.ToString();

// replace illegal characters in XML documents with their entity references 

        data = data.Replace("&", "&amp;");

        data = data.Replace("\"", "&quot;");

        data = data.Replace("'", "&apos;");

        data = data.Replace("<", "&lt;");

        data = data.Replace(">", "&gt;");

  return data;





This is the complete description on creating RSS feed for website. I hope this article will help you in creating your RSS feeds.

Don't want to miss updates? Please click the below button!

Follow MindStick