ARTICLE

Building RSS Feeds using RSS Document 2.0 and VB.NET

Posted by Ashish Singhal Articles | Visual Basic 2010 January 06, 2006
This article and attached source code shows how to build a RRS Feed using RSS Document 2.0 specifications.
 
Reader Level:

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.

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.

NOTE: THIS ARTICLE IS CONVERTED FROM C# TO VB.NET USING A CONVERSION TOOL. ORIGINAL ARTICLE CAN BE FOUND ON C# CORNER (WWW.C-SHARPCORNER.COM).

share this article :
post comment
 

Why I get this "HttpContext" error or underlined with blue color in vb?

Posted by ferdy panarto Oct 19, 2009
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Nevron Diagram
Become a Sponsor