Friday, October 31, 2008

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

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 :









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.

Imports System

Imports System.Data

Imports System.Xml

Imports System.Web

Imports System.Text

Sub GetXML(ds As DataSet) '

Try

HttpContext.Current.Response.Clear()

HttpContext.Current.Response.ContentType = "text/xml"

Dim objX As 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 Not (ds Is Nothing) Then

Dim dr As DataRow

For Each 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()

Next dr

End If

objX.WriteEndElement()

objX.WriteEndElement()

objX.WriteEndDocument()

objX.Flush()

objX.Close()

Catch ex As Exception

HttpContext.Current.Response.Write(ex.ToString())

End Try
End Sub 'GetXML

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.

C-Sharpcorner