SlideShare a Scribd company logo
RSS Feed using ASP.NET & Linq http://www.livetolearn.in
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> <channel> <item> <title></title> <description></description> <link></link> <pubDate></pubDate> <!--..............................--> </item> </channel> </rss> http://www.livetolearn.in
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( &quot;1.0&quot;,  Nothing, Nothing)) rssdoc.Add( New XComment( &quot;My RSS Feed uses XML to Linq datasource&quot;)) Dim rssrootelement As New XElement( &quot;rss&quot;,  New XAttribute( &quot;version&quot;, &quot;2.0&quot;)) Dim rsschannel As New XElement( &quot;channel&quot;) Dim rsstitle As New XElement( &quot;title&quot;, &quot;RK's News Channel&quot;) rsschannel.Add(rsstitle) Dim rssdesc As New XElement( &quot;description&quot;, &quot;Description of Channel&quot;) rsschannel.Add(rssdesc) Dim rsslink As New XElement( &quot;link&quot;, &quot;http://www.livetolearn.in/&quot;) rsschannel.Add(rsslink) Dim intCtr As Integer Dim rssitem As XElement RSS Document Comment RSS Channel Title (Appears at title bar) RSS Title Link http://www.livetolearn.in
For intCtr = 0 To 10 rssitem =  New XElement( &quot;item&quot;, _ New XElement( &quot;title&quot;, &quot;This is item number &quot; & intCtr.ToString), _ New XElement( &quot;description&quot;, &quot;Description for item # &quot; & _ intCtr.ToString), _ New XElement( &quot;link&quot;, &quot;http://www.livetolearn.in/item&quot; & _ intCtr.ToString &  &quot;.aspx&quot;)) rsschannel.Add(rssitem) Next rssrootelement.Add(rsschannel) rssdoc.Add(rssrootelement) rssdoc.Save(( New System.IO.StreamWriter _ (context.Response.OutputStream))) End Sub This for loop creates 10 sample items with Description.  http://www.livetolearn.in
Now, browse the rsshandler.ashx with Internet Explorer 7 and above or Firefox http://www.livetolearn.in
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. ******** http://www.livetolearn.in

More Related Content

PDF
분데스리가일정→→W­Е­4­9.сом←←유료픽キ분데스리가キ프리메라리가
PDF
TuleapCon 2018. Tuleap Development circa end of march 2018
PDF
Remote Config REST API and Versioning
PPTX
Anatomy of API Content Distribution
PDF
Intro to developing for @twitterapi
PPTX
Introduction to .NET Programming
PPT
Transforming Xml Data Into Html
PDF
Designing Teams for Emerging Challenges
분데스리가일정→→W­Е­4­9.сом←←유료픽キ분데스리가キ프리메라리가
TuleapCon 2018. Tuleap Development circa end of march 2018
Remote Config REST API and Versioning
Anatomy of API Content Distribution
Intro to developing for @twitterapi
Introduction to .NET Programming
Transforming Xml Data Into Html
Designing Teams for Emerging Challenges

Similar to Creating an RSS feed (20)

PPTX
Php Mysql Feedrss
PPT
Php Rss
PPT
Sencha Touch Intro
PPT
Solr Presentation
PPTX
Schematron and Other Useful Tools
PPT
Struts2
PPT
Struts Portlet
PPT
JSP Standart Tag Lİbrary - JSTL
PPT
Itemscript, a specification for RESTful JSON integration
PPT
Xml Zoe
PPT
Xml Zoe
ODP
jQuery : Talk to server with Ajax
PPT
Wso2 Scenarios Esb Webinar July 1st
PPT
Processing XML with Java
PPTX
E pi servereasysearchtechnicaloverview
PPT
KMUTNB - Internet Programming 3/7
PPT
Vb.Net Web Forms
PPT
PPT
XML Transformations With PHP
Php Mysql Feedrss
Php Rss
Sencha Touch Intro
Solr Presentation
Schematron and Other Useful Tools
Struts2
Struts Portlet
JSP Standart Tag Lİbrary - JSTL
Itemscript, a specification for RESTful JSON integration
Xml Zoe
Xml Zoe
jQuery : Talk to server with Ajax
Wso2 Scenarios Esb Webinar July 1st
Processing XML with Java
E pi servereasysearchtechnicaloverview
KMUTNB - Internet Programming 3/7
Vb.Net Web Forms
XML Transformations With PHP
Ad

Creating an RSS feed

  • 1. RSS Feed using ASP.NET & Linq http://www.livetolearn.in
  • 2. 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
  • 3. <rss> <channel> <item> <title></title> <description></description> <link></link> <pubDate></pubDate> <!--..............................--> </item> </channel> </rss> http://www.livetolearn.in
  • 4. 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
  • 5. Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim rssdoc As New XDocument(New XDeclaration( &quot;1.0&quot;, Nothing, Nothing)) rssdoc.Add( New XComment( &quot;My RSS Feed uses XML to Linq datasource&quot;)) Dim rssrootelement As New XElement( &quot;rss&quot;, New XAttribute( &quot;version&quot;, &quot;2.0&quot;)) Dim rsschannel As New XElement( &quot;channel&quot;) Dim rsstitle As New XElement( &quot;title&quot;, &quot;RK's News Channel&quot;) rsschannel.Add(rsstitle) Dim rssdesc As New XElement( &quot;description&quot;, &quot;Description of Channel&quot;) rsschannel.Add(rssdesc) Dim rsslink As New XElement( &quot;link&quot;, &quot;http://www.livetolearn.in/&quot;) rsschannel.Add(rsslink) Dim intCtr As Integer Dim rssitem As XElement RSS Document Comment RSS Channel Title (Appears at title bar) RSS Title Link http://www.livetolearn.in
  • 6. For intCtr = 0 To 10 rssitem = New XElement( &quot;item&quot;, _ New XElement( &quot;title&quot;, &quot;This is item number &quot; & intCtr.ToString), _ New XElement( &quot;description&quot;, &quot;Description for item # &quot; & _ intCtr.ToString), _ New XElement( &quot;link&quot;, &quot;http://www.livetolearn.in/item&quot; & _ intCtr.ToString & &quot;.aspx&quot;)) rsschannel.Add(rssitem) Next rssrootelement.Add(rsschannel) rssdoc.Add(rssrootelement) rssdoc.Save(( New System.IO.StreamWriter _ (context.Response.OutputStream))) End Sub This for loop creates 10 sample items with Description. http://www.livetolearn.in
  • 7. Now, browse the rsshandler.ashx with Internet Explorer 7 and above or Firefox http://www.livetolearn.in
  • 8. Displaying XML data http://www.livetolearn.in
  • 9. 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
  • 10. By adding more items in Item Template (e.g. Text box), we can display description from RSS feed. ******** http://www.livetolearn.in