This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
Overview
Download & View Creating Rss Feed as PDF for free.
RSS Feed RSS is a format for an XML document that describes a list of items, such as blog entries or news headlines. The document may just be a stream of XML created on the fly rather than a static file.
http://www.livetolearn.in
RSS XML Markup <description>
http://www.livetolearn.in
Creating an RSS Feed Add a generic handler named rsshandler.ashx Add import directive Imports System.Xml.Linq Replace the process request() subroutine as follows
http://www.livetolearn.in
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim rssdoc As New XDocument(New XDeclaration("1.0", Nothing, Nothing)) rssdoc.Add(New XComment("My RSS Feed uses XML to Linq datasource")) Dim rssrootelement As New XElement("rss", New RSS Document Comment XAttribute("version", "2.0")) Dim rsschannel As New XElement("channel") Dim rsstitle As New XElement("title", "RK's News Channel") rsschannel.Add(rsstitle) Dim rssdescRSS As Channel New XElement("description", Title (Appears at title bar) "Description of Channel") rsschannel.Add(rssdesc) Dim rsslink As New XElement("link", "http://www.livetolearn.in/") rsschannel.Add(rsslink) Dim intCtr As Integer RSS Title Link Dim rssitem As XElement
http://www.livetolearn.in
For intCtr = 0 To 10 rssitem = New XElement("item", _ New XElement("title", "This is item number " & intCtr.ToString), _ 10 sample items with Description. This for loop creates New XElement("description", "Description for item # " & _ intCtr.ToString), _ New XElement("link", "http://www.livetolearn.in/item" & _ intCtr.ToString & ".aspx")) rsschannel.Add(rssitem) Next rssrootelement.Add(rsschannel) rssdoc.Add(rssrootelement) rssdoc.Save((New System.IO.StreamWriter _ (context.Response.OutputStream))) End Sub
http://www.livetolearn.in
Now, browse the rsshandler.ashx with Internet Explorer 7 and above or Firefox
http://www.livetolearn.in
Displaying RSS Feed Displaying XML data
http://www.livetolearn.in
Add an XmlDataSource control to a ASP.NET page Click smart tag Choose configure data source Enter the URL of the RSS feed For example http://www.livetolearn.in/blog/?feed=rss2 Type the following in Xpath expression text box Rss/channel/item Add a data list control and set source to Xmldatasource1, Edit Item template of data list control Add a hyper link control inside the item template Set it’s data binding property as follows Navigate URL – xPath(“link”) xPath(“title”) It displays the list of items from rss feed.
http://www.livetolearn.in
By adding more items in Item Template (e.g. Text box), we can display description from RSS feed.