473,808 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Rss Feed

Hi
I am trying to provide infrastructure for RSS feeds on my Website. I
dont intend to build any news aggregators. I just want my website to
be enabled for providing RSS Feeds. I am using ASP.NET and C#. And I
dont know where and how to begin. Do you know of any tutorials that
may help me do that?
Thanks,
Sonal.
Nov 16 '05 #1
5 2269
There's nothing special you need to do to enable a website other than
developer the code to create or consume XML.

If you intend to create feeds that can be validated you should make sure
your hosting provide has configured IIS to support the application/xml MIME
Type for .rss, .rdf, and .xml file types.
--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REM OVETHISTEXTmetr omilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/



"Sonal" <sm*********@gm ail.com> wrote in message
news:b3******** *************** ***@posting.goo gle.com...
Hi
I am trying to provide infrastructure for RSS feeds on my Website. I
dont intend to build any news aggregators. I just want my website to
be enabled for providing RSS Feeds. I am using ASP.NET and C#. And I
dont know where and how to begin. Do you know of any tutorials that
may help me do that?
Thanks,
Sonal.

Nov 16 '05 #2

"Sonal" <sm*********@gm ail.com> wrote in message
news:b3******** *************** ***@posting.goo gle.com...
Hi
I am trying to provide infrastructure for RSS feeds on my Website. I
dont intend to build any news aggregators. I just want my website to
be enabled for providing RSS Feeds. I am using ASP.NET and C#. And I
dont know where and how to begin. Do you know of any tutorials that
may help me do that?
Thanks,
Sonal.


Here is a simple ASPX example, the NewsDAL implemenation is left as an
exercise for the reader :)

<!-- RSS.ASPX -->
<%@ Page language="vb" ContentType="te xt/xml" Codebehind="rss .aspx.vb"
AutoEventWireup ="false" Inherits="news. rss" EnableSessionSt ate="False"
enableViewState ="False" buffer="True"%>
<asp:Repeater id="rptRSS" runat="server">
<HeaderTemplate >
<rss version="2.0">
<channel>
<title><%=Chann elTitle%></title>
<link><%=Channe lLink%></link>
<description>
<%=ChannelDescr iption%>
</description>
</HeaderTemplate>

<ItemTemplate >
<item>
<title><%# FormatForXML(Da taBinder.Eval(C ontainer.DataIt em, "Title"))
%></title>
<description><% # FormatForXML(Da taBinder.Eval(C ontainer.DataIt em,
"Descriptio n")) %></description>
<link>http://<%=Request.Serv erVariables("SE RVER_NAME") &
Request.Applica tionPath %>/Story.aspx?ID=< %#
DataBinder.Eval (Container.Data Item, "ArticleID" ) %></link>
<author><%# FormatForXML(Da taBinder.Eval(C ontainer.DataIt em, "Author"))
%></author>
<pubDate><%# String.Format(" {0:R}", DataBinder.Eval (Container.Data Item,
"DatePublished" )) %></pubDate>
</item>
</ItemTemplate>

<FooterTemplate >
</channel>
</rss>
</FooterTemplate>
</asp:Repeater>
' rss.aspx.vb
Imports System.Xml

Public Class rss
Inherits System.Web.UI.P age
Public ChannelTitle As String = ""
Public ChannelLink As String = ""
Public ChannelDescript ion As String = ""

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region
Protected WithEvents rptRSS As System.Web.UI.W ebControls.Repe ater

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim ArticleCount As Integer
Dim ChannelID As Integer
Dim data As NewsDAL.Data = New NewsDAL.Data(Gl obal.ConnString )

Try
Try
ArticleCount = Integer.Parse(R equest.QueryStr ing("Count"))
Catch
ArticleCount = 5
End Try
Try
ChannelID = Integer.Parse(R equest.QueryStr ing("ChannelID" ))
Catch
ChannelID = 1
End Try

Dim ds As New DataSet
data.FillRSSCha nnels_Get(ds, ChannelID)
Dim dr As DataRow = ds.Tables(0).Ro ws(0)
ChannelTitle = FormatForXML(dr ("Title").ToStr ing())
ChannelLink = FormatForXML(dr ("Link").ToStri ng())
ChannelDescript ion = FormatForXML(dr ("Description") .ToString())
Catch ex As Exception
Response.Clear( )
Response.Write([String].Format("<error >Channel {0}</error>", ex.Message))
Response.End()
End Try
Try
Dim ds As New DataSet
data.FillArticl es_GetListForCh annel(ds, ArticleCount, ChannelID)
Dim dv As New DataView
dv.Table = ds.Tables(0)
dv.Sort = "DatePublis hed DESC"
rptRSS.DataSour ce = dv
rptRSS.DataBind ()
Catch ex As Exception
Response.Clear( )
Response.Write([String].Format("<error >Articles {0}</error>",
ex.Message))
Response.End()
End Try
data = Nothing

End Sub
Protected Function FormatForXML(By Val input As Object) As String

Dim s As String = input.ToString( ) '; // cast the input to a string

'// replace those characters disallowed in XML documents
s = s.Replace("&", "&amp;")
s = s.Replace("""", "&quot;")
s = s.Replace("'", "&apos;")
s = s.Replace("<", "&lt;")
s = s.Replace(">", "&gt;")

Return s
End Function
End Class

Nov 16 '05 #3

"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:eb******** ******@TK2MSFTN GP12.phx.gbl...

"Sonal" <sm*********@gm ail.com> wrote in message
news:b3******** *************** ***@posting.goo gle.com...
Hi
I am trying to provide infrastructure for RSS feeds on my Website. I
dont intend to build any news aggregators. I just want my website to
be enabled for providing RSS Feeds. I am using ASP.NET and C#. And I
dont know where and how to begin. Do you know of any tutorials that
may help me do that?
Thanks,
Sonal.
Here is a simple ASPX example, the NewsDAL implemenation is left as an
exercise for the reader :)

Oh my, I did it again! (posting vb instead of C#

Here is the C# version converted at
http://www.developerfusion.com/utili...btocsharp.aspx
(untested)

<!-- RSS.ASPX -->
<%@ Page language="vb" ContentType="te xt/xml" Codebehind="rss .aspx.cs"
AutoEventWireup ="false" Inherits="news. rss" EnableSessionSt ate="False"
enableViewState ="False" buffer="True"%>
<asp:Repeater id="rptRSS" runat="server">
<HeaderTemplate >
<rss version="2.0">
<channel>
<title><%=Chann elTitle%></title>
<link><%=Channe lLink%></link>
<description>
<%=ChannelDescr iption%>
</description>
</HeaderTemplate>

<ItemTemplate >
<item>
<title><%# FormatForXML(Da taBinder.Eval(C ontainer.DataIt em, "Title"))
%></title>
<description><% # FormatForXML(Da taBinder.Eval(C ontainer.DataIt em,
"Descriptio n")) %></description>
<link>http://<%=Request.Serv erVariables("SE RVER_NAME") &
Request.Applica tionPath %>/Story.aspx?ID=< %#
DataBinder.Eval (Container.Data Item, "ArticleID" ) %></link>
<author><%# FormatForXML(Da taBinder.Eval(C ontainer.DataIt em, "Author"))
%></author> <pubDate><%# String.Format(" {0:R}", DataBinder.Eval (Container.Data Item,

"DatePublished" )) %></pubDate>
</item>
</ItemTemplate>

<FooterTemplate >
</channel>
</rss>
</FooterTemplate>
</asp:Repeater>

// rss.aspx.cs
using System.Xml;
public class rss : System.Web.UI.P age
{
public string ChannelTitle = "";
public string ChannelLink = "";
public string ChannelDescript ion = "";

[System.Diagnost ics.DebuggerSte pThrough()]
private void InitializeCompo nent()
{
}
private object designerPlaceho lderDeclaration ;

private void Page_Init(objec t sender, System.EventArg s e)
{
InitializeCompo nent();
}
protected System.Web.UI.W ebControls.Repe ater rptRSS;

private void Page_Load(objec t sender, System.EventArg s e)
{
int ArticleCount;
int ChannelID;
NewsDAL.Data data = new NewsDAL.Data(Gl obal.ConnString );
try {
try {
ArticleCount = int.Parse(Reque st.QueryString( "Count"));
} catch (void ) {
ArticleCount = 5;
}
try {
ChannelID = int.Parse(Reque st.QueryString( "ChannelID" ));
} catch (void ) {
ChannelID = 1;
}
DataSet ds = new DataSet();
data.FillRSSCha nnels_Get(ds, ChannelID);
DataRow dr = ds.Tables(0).Ro ws(0);
ChannelTitle = FormatForXML(dr ("Title").ToStr ing());
ChannelLink = FormatForXML(dr ("Link").ToStri ng());
ChannelDescript ion = FormatForXML(dr ("Description") .ToString());
} catch (Exception ex) {
Response.Clear( );
Response.Write( String.Format(" <error>Channe l {0}</error>",
ex.Message));
Response.End();
}
try {
DataSet ds = new DataSet();
data.FillArticl es_GetListForCh annel(ds, ArticleCount, ChannelID);
DataView dv = new DataView();
dv.Table = ds.Tables(0);
dv.Sort = "DatePublis hed DESC";
rptRSS.DataSour ce = dv;
rptRSS.DataBind ();
} catch (Exception ex) {
Response.Clear( );
Response.Write( String.Format(" <error>Articl es {0}</error>",
ex.Message));
Response.End();
}
data = null;
}

protected string FormatForXML(ob ject input)
{
string s = input.ToString( );
s = s.Replace("&", "&amp;");
s = s.Replace(""", "&quot;");
s = s.Replace("'", "&apos;");
s = s.Replace("<", "&lt;");
s = s.Replace(">", "&gt;");
return s;
}
}
Nov 16 '05 #4
Rss can be a fairly rich format, or it can be insanely simple. Below,
Jim has done a great job of using existing page controls to generate
his own RSS feed without laying a finger on the XML classes.

To expand the example, you can do more than just run inline repeater
items. You can load user controls that render each item if you have
custom RSS elements that need to be displayed in each item.

You can also load user controls for the <description> element which
has the extreme benefit of allowing you to bind multiple types of
content to the same RSS feed and render each of them differently.

A second feature of this binding will be allowing your existing view
controls to be used in the RSS feed to generate the content or
<description> area. That means if you have a rich view already
displayed elsewhere in your site, you can reuse that logic so that
your RSS feeds look really awesome.
---

The easiest manner of generating RSS is still to use an XmlWriter to
spit out XML directly. It gives you a natural feel for every token in
the stream, and it happens to be one of the fastest methods for
creating XML compliant feeds.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:u%******** ********@TK2MSF TNGP09.phx.gbl. ..

"Jim Hughes" <NO*********@Ho tmail.com> wrote in message
news:eb******** ******@TK2MSFTN GP12.phx.gbl...

"Sonal" <sm*********@gm ail.com> wrote in message
news:b3******** *************** ***@posting.goo gle.com...
Hi
I am trying to provide infrastructure for RSS feeds on my Website. I
dont intend to build any news aggregators. I just want my website to
be enabled for providing RSS Feeds. I am using ASP.NET and C#. And I
dont know where and how to begin. Do you know of any tutorials that
may help me do that?
Thanks,
Sonal.


Here is a simple ASPX example, the NewsDAL implemenation is left as an
exercise for the reader :)

Oh my, I did it again! (posting vb instead of C#

Here is the C# version converted at
http://www.developerfusion.com/utili...btocsharp.aspx
(untested)

<!-- RSS.ASPX -->
<%@ Page language="vb" ContentType="te xt/xml" Codebehind="rss .aspx.cs"
AutoEventWireup ="false" Inherits="news. rss" EnableSessionSt ate="False"
enableViewState ="False" buffer="True"%>
<asp:Repeater id="rptRSS" runat="server">
<HeaderTemplate >
<rss version="2.0">
<channel>
<title><%=Chann elTitle%></title>
<link><%=Channe lLink%></link>
<description>
<%=ChannelDescr iption%>
</description>
</HeaderTemplate>

<ItemTemplate >
<item>
<title><%# FormatForXML(Da taBinder.Eval(C ontainer.DataIt em, "Title"))
%></title>
<description><% # FormatForXML(Da taBinder.Eval(C ontainer.DataIt em,
"Descriptio n")) %></description>
<link>http://<%=Request.Serv erVariables("SE RVER_NAME") &
Request.Applica tionPath %>/Story.aspx?ID=< %#
DataBinder.Eval (Container.Data Item, "ArticleID" ) %></link>
<author><%# FormatForXML(Da taBinder.Eval(C ontainer.DataIt em, "Author"))
%></author>
<pubDate><%# String.Format(" {0:R}", DataBinder.Eval (Container.Data Item,

"DatePublished" )) %></pubDate>
</item>
</ItemTemplate>

<FooterTemplate >
</channel>
</rss>
</FooterTemplate>
</asp:Repeater>

// rss.aspx.cs
using System.Xml;
public class rss : System.Web.UI.P age
{
public string ChannelTitle = "";
public string ChannelLink = "";
public string ChannelDescript ion = "";

[System.Diagnost ics.DebuggerSte pThrough()]
private void InitializeCompo nent()
{
}
private object designerPlaceho lderDeclaration ;

private void Page_Init(objec t sender, System.EventArg s e)
{
InitializeCompo nent();
}
protected System.Web.UI.W ebControls.Repe ater rptRSS;

private void Page_Load(objec t sender, System.EventArg s e)
{
int ArticleCount;
int ChannelID;
NewsDAL.Data data = new NewsDAL.Data(Gl obal.ConnString );
try {
try {
ArticleCount = int.Parse(Reque st.QueryString( "Count"));
} catch (void ) {
ArticleCount = 5;
}
try {
ChannelID = int.Parse(Reque st.QueryString( "ChannelID" ));
} catch (void ) {
ChannelID = 1;
}
DataSet ds = new DataSet();
data.FillRSSCha nnels_Get(ds, ChannelID);
DataRow dr = ds.Tables(0).Ro ws(0);
ChannelTitle = FormatForXML(dr ("Title").ToStr ing());
ChannelLink = FormatForXML(dr ("Link").ToStri ng());
ChannelDescript ion = FormatForXML(dr ("Description") .ToString());
} catch (Exception ex) {
Response.Clear( );
Response.Write( String.Format(" <error>Channe l {0}</error>", ex.Message));
Response.End();
}
try {
DataSet ds = new DataSet();
data.FillArticl es_GetListForCh annel(ds, ArticleCount, ChannelID);
DataView dv = new DataView();
dv.Table = ds.Tables(0);
dv.Sort = "DatePublis hed DESC";
rptRSS.DataSour ce = dv;
rptRSS.DataBind ();
} catch (Exception ex) {
Response.Clear( );
Response.Write( String.Format(" <error>Articl es {0}</error>", ex.Message));
Response.End();
}
data = null;
}

protected string FormatForXML(ob ject input)
{
string s = input.ToString( );
s = s.Replace("&", "&amp;");
s = s.Replace(""", "&quot;");
s = s.Replace("'", "&apos;");
s = s.Replace("<", "&lt;");
s = s.Replace(">", "&gt;");
return s;
}
}

Nov 16 '05 #5
Thanks all of you.
That helped.
-Sonal
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1426
by: Kraft Bernhard | last post by:
Hallo list, I don't know if this is a apropriate Newsgroup for this thread but I found it via google and there are already some RSS question in here so I'm just asking: I have written a RSS Feed which fetches the list of new Extensions for the CMS Typo3 (www.typo3.org) and stores them in a database. Whenever somebody requests the RSS Feed the Feed XML is generated out of the database.
2
4297
by: Brad Sanders | last post by:
Hello All, Thanks to Richard's answer to my last post I understand now what I have to do, but.. How do I put a Line Feed or a Form Feed into a text file? Looking throught the .net help it mentions \f but illustrates no way write it to a text file. Thanks
1
2577
by: Steve | last post by:
I have a script that has been modified from one that I found on the internet to display RSS feeds in html. The script works fine for most RSS feeds but there are a number that it fails on with the error "End tag 'head' does not match the start tag 'meta'". Does any one on here have any experience with this? The script is shown below, the Neowin feed works but the google feed does not. Any help would be appreciated.
6
2373
by: affiliateian | last post by:
Total newbie here for this so please be patient. We manually update our XML feed when we publish an article on our website. Can we add a javascript tracking pixel (from phpadsnew) into the XML file to track how many times our feed was accessed? Just to get a rough idea how manyh subscribers we have? Not sure if copying and pasting a javascript into the XML source would work.
4
4236
by: Florian Lindner | last post by:
Hello, I'm looking for python RSS feed parser library. Feedparser http://feedparser.org/ does not seem to maintained anymore. What alternatives are recommendable? Thanks, Florian
5
2437
by: Ed Flecko | last post by:
Hi folks, I'm trying to figure out this whole RSS feed thing. I've created my .xml file to use for my feed, and my browsers "recognize" that I have an RSS feed, and you can subscribe, etc., etc. Here's why I "think" I want to use an RSS feed, and what I'm confused about. I have one file (and one file only) on my web site that changes
1
1652
by: paul.hester | last post by:
Hi all, I work for a classified-type site and am planning on having an RSS feed for each category. I understand the basics of RSS, but I can't decide how often to update each RSS feed. Each category will probably have several new listings every hour. What's generally the recommended update frequency for an RSS feed? Also, in each update, do you exclude content that was in previous feeds, or do you leave it up to the reader to sort out...
4
1970
by: Blake Garner | last post by:
I'm looking for suggestions on how to approach generating rss feed ..xml files using python. What modules to people recommend I start with? Thanks! Blake
10
2396
by: bhass | last post by:
From my other post I am making a simple program that creates an RSS feed with Python. Now when I run my program so far, I get errors. It says "something is not defined". The word something is replaced by the name of the function I'm trying to use. my article function when ran, comes up with "article is not defined" etc. Here's my code: What is wrong with it? #!/usr/bin/env python import ftplib import getpass def mainfeed(): ...
2
3234
jamwil
by: jamwil | last post by:
What's up guys. I'm having some issues... I've created a method as part of my lifestreaming class which takes an rss feed, and puts the data into a database... It's fairly simple... Check it....///// // feed // // LOADS THE RSS FEED FOR // LOOPS THROUGH AND FORMATS/FILTERS POSTS // PULLS THE TIMESTAMP OF THE LATEST UPDATE FROM THE DB // IF THERE ARE NEW POSTS, ADD THEM TO THE DATABASE ///// public function feed($feed,$type) { if...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10628
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10373
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9195
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.