Reader Level:
ARTICLE

Building RSS Feeds using RSS Document 2.0

Posted by Ashish Singhal Articles | How do I January 06, 2006
This article and attached source code shows how to build a RRS Feed using RSS Document 2.0 specifications.
  • 2
  • 0
  • 24887

This article will explain about the making of RSS document using ASP.NET and C#.

RSS[Really Simple Syndication] is a web content syndication format. RSS is a discourse of XML. All RSS files must follow to the XML 1.0 specification, says the World Wide Web Consortium (W3C) website.

Order OF RSS document :

<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="0.91">
   <
channel>
       <
item>
       </
item>
   </
channel>
</
rss>

RSS-Reader programs called news aggregators are popular in the weblogging community. Many weblogs make content available in RSS. A news aggregator can help you keep up with all your favorite weblogs by checking their RSS feeds and displaying new items from each of them.

//Call this function passing data in it and set ur fields below.
using System;
using System.Data;
using System.Xml;
using System.Web;
using System.Text;
public
void GetXML(DataSet ds)
{
try
{
HttpContext
.Current.Response.Clear();
HttpContext
.Current.Response.ContentType = "text/xml";
XmlTextWriter objX
= new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
objX
.WriteStartDocument();
objX
.WriteStartElement("rss");
objX
.WriteAttributeString("version","2.0");
objX
.WriteStartElement("channel");
objX
.WriteElementString("title", "C-Sharpcorner Articles");
objX
.WriteElementString("link","http://www.c-sharpcorner.com");
objX
.WriteElementString("description","Watch C-Sharpcorner latest articles");
objX
.WriteElementString("copyright","© 2000 - 2006  Mindcracker LLC. All Rights Reserved");
objX
.WriteElementString("ttl","5");
if(ds != null)
{
foreach(DataRow dr in ds.Tables[0].Rows)
{
objX
.WriteStartElement("item");
objX
.WriteElementString("title",dr["title"].ToString());
objX
.WriteElementString("description",dr["description"].ToString());
objX.WriteElementString("link",dr["Path"].ToString());
objX.WriteElementString("link",dr["URL"].ToString());
objX
.WriteElementString("pubDate",dr["date"].ToString());
objX
.WriteElementString("author",dr["author"].ToString());
objX
.WriteEndElement();
}
}
objX
.WriteEndElement();
objX
.WriteEndElement();
objX
.WriteEndDocument();
objX
.Flush();
objX
.Close();
}
catch(Exception ex){
HttpContext
.Current.Response.Write(ex.ToString());
}
}

RSS feed often contains only the opening paragraph of each posted article. The bulk of the article is generally kept on the Web site, the URL for which is included in the RSS feed, so that users who are interested can click through and read the whole thing. So, your RSS feed is basically another way for users to subscribe to announcements of new articles, features, etc., for which they still have to come to your site, and view your pages in order to view the whole article.

COMMENT USING

Trending up