473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2246
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*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/



"Sonal" <sm*********@gmail.com> wrote in message
news:b3**************************@posting.google.c om...
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*********@gmail.com> wrote in message
news:b3**************************@posting.google.c om...
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="text/xml" Codebehind="rss.aspx.vb"
AutoEventWireup="false" Inherits="news.rss" EnableSessionState="False"
enableViewState="False" buffer="True"%>
<asp:Repeater id="rptRSS" runat="server">
<HeaderTemplate>
<rss version="2.0">
<channel>
<title><%=ChannelTitle%></title>
<link><%=ChannelLink%></link>
<description>
<%=ChannelDescription%>
</description>
</HeaderTemplate>

<ItemTemplate>
<item>
<title><%# FormatForXML(DataBinder.Eval(Container.DataItem, "Title"))
%></title>
<description><%# FormatForXML(DataBinder.Eval(Container.DataItem,
"Description")) %></description>
<link>http://<%=Request.ServerVariables("SERVER_NAME") &
Request.ApplicationPath %>/Story.aspx?ID=<%#
DataBinder.Eval(Container.DataItem, "ArticleID") %></link>
<author><%# FormatForXML(DataBinder.Eval(Container.DataItem, "Author"))
%></author>
<pubDate><%# String.Format("{0:R}", DataBinder.Eval(Container.DataItem,
"DatePublished")) %></pubDate>
</item>
</ItemTemplate>

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

Public Class rss
Inherits System.Web.UI.Page
Public ChannelTitle As String = ""
Public ChannelLink As String = ""
Public ChannelDescription As String = ""

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

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

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

#End Region
Protected WithEvents rptRSS As System.Web.UI.WebControls.Repeater

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

Try
Try
ArticleCount = Integer.Parse(Request.QueryString("Count"))
Catch
ArticleCount = 5
End Try
Try
ChannelID = Integer.Parse(Request.QueryString("ChannelID"))
Catch
ChannelID = 1
End Try

Dim ds As New DataSet
data.FillRSSChannels_Get(ds, ChannelID)
Dim dr As DataRow = ds.Tables(0).Rows(0)
ChannelTitle = FormatForXML(dr("Title").ToString())
ChannelLink = FormatForXML(dr("Link").ToString())
ChannelDescription = 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.FillArticles_GetListForChannel(ds, ArticleCount, ChannelID)
Dim dv As New DataView
dv.Table = ds.Tables(0)
dv.Sort = "DatePublished DESC"
rptRSS.DataSource = 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(ByVal 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*********@Hotmail.com> wrote in message
news:eb**************@TK2MSFTNGP12.phx.gbl...

"Sonal" <sm*********@gmail.com> wrote in message
news:b3**************************@posting.google.c om...
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="text/xml" Codebehind="rss.aspx.cs"
AutoEventWireup="false" Inherits="news.rss" EnableSessionState="False"
enableViewState="False" buffer="True"%>
<asp:Repeater id="rptRSS" runat="server">
<HeaderTemplate>
<rss version="2.0">
<channel>
<title><%=ChannelTitle%></title>
<link><%=ChannelLink%></link>
<description>
<%=ChannelDescription%>
</description>
</HeaderTemplate>

<ItemTemplate>
<item>
<title><%# FormatForXML(DataBinder.Eval(Container.DataItem, "Title"))
%></title>
<description><%# FormatForXML(DataBinder.Eval(Container.DataItem,
"Description")) %></description>
<link>http://<%=Request.ServerVariables("SERVER_NAME") &
Request.ApplicationPath %>/Story.aspx?ID=<%#
DataBinder.Eval(Container.DataItem, "ArticleID") %></link>
<author><%# FormatForXML(DataBinder.Eval(Container.DataItem, "Author"))
%></author> <pubDate><%# String.Format("{0:R}", DataBinder.Eval(Container.DataItem,

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

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

// rss.aspx.cs
using System.Xml;
public class rss : System.Web.UI.Page
{
public string ChannelTitle = "";
public string ChannelLink = "";
public string ChannelDescription = "";

[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent()
{
}
private object designerPlaceholderDeclaration;

private void Page_Init(object sender, System.EventArgs e)
{
InitializeComponent();
}
protected System.Web.UI.WebControls.Repeater rptRSS;

private void Page_Load(object sender, System.EventArgs e)
{
int ArticleCount;
int ChannelID;
NewsDAL.Data data = new NewsDAL.Data(Global.ConnString);
try {
try {
ArticleCount = int.Parse(Request.QueryString("Count"));
} catch (void ) {
ArticleCount = 5;
}
try {
ChannelID = int.Parse(Request.QueryString("ChannelID"));
} catch (void ) {
ChannelID = 1;
}
DataSet ds = new DataSet();
data.FillRSSChannels_Get(ds, ChannelID);
DataRow dr = ds.Tables(0).Rows(0);
ChannelTitle = FormatForXML(dr("Title").ToString());
ChannelLink = FormatForXML(dr("Link").ToString());
ChannelDescription = FormatForXML(dr("Description").ToString());
} catch (Exception ex) {
Response.Clear();
Response.Write(String.Format("<error>Channel {0}</error>",
ex.Message));
Response.End();
}
try {
DataSet ds = new DataSet();
data.FillArticles_GetListForChannel(ds, ArticleCount, ChannelID);
DataView dv = new DataView();
dv.Table = ds.Tables(0);
dv.Sort = "DatePublished DESC";
rptRSS.DataSource = dv;
rptRSS.DataBind();
} catch (Exception ex) {
Response.Clear();
Response.Write(String.Format("<error>Articles {0}</error>",
ex.Message));
Response.End();
}
data = null;
}

protected string FormatForXML(object 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*********@Hotmail.com> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...

"Jim Hughes" <NO*********@Hotmail.com> wrote in message
news:eb**************@TK2MSFTNGP12.phx.gbl...

"Sonal" <sm*********@gmail.com> wrote in message
news:b3**************************@posting.google.c om...
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="text/xml" Codebehind="rss.aspx.cs"
AutoEventWireup="false" Inherits="news.rss" EnableSessionState="False"
enableViewState="False" buffer="True"%>
<asp:Repeater id="rptRSS" runat="server">
<HeaderTemplate>
<rss version="2.0">
<channel>
<title><%=ChannelTitle%></title>
<link><%=ChannelLink%></link>
<description>
<%=ChannelDescription%>
</description>
</HeaderTemplate>

<ItemTemplate>
<item>
<title><%# FormatForXML(DataBinder.Eval(Container.DataItem, "Title"))
%></title>
<description><%# FormatForXML(DataBinder.Eval(Container.DataItem,
"Description")) %></description>
<link>http://<%=Request.ServerVariables("SERVER_NAME") &
Request.ApplicationPath %>/Story.aspx?ID=<%#
DataBinder.Eval(Container.DataItem, "ArticleID") %></link>
<author><%# FormatForXML(DataBinder.Eval(Container.DataItem, "Author"))
%></author>
<pubDate><%# String.Format("{0:R}", DataBinder.Eval(Container.DataItem,

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

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

// rss.aspx.cs
using System.Xml;
public class rss : System.Web.UI.Page
{
public string ChannelTitle = "";
public string ChannelLink = "";
public string ChannelDescription = "";

[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent()
{
}
private object designerPlaceholderDeclaration;

private void Page_Init(object sender, System.EventArgs e)
{
InitializeComponent();
}
protected System.Web.UI.WebControls.Repeater rptRSS;

private void Page_Load(object sender, System.EventArgs e)
{
int ArticleCount;
int ChannelID;
NewsDAL.Data data = new NewsDAL.Data(Global.ConnString);
try {
try {
ArticleCount = int.Parse(Request.QueryString("Count"));
} catch (void ) {
ArticleCount = 5;
}
try {
ChannelID = int.Parse(Request.QueryString("ChannelID"));
} catch (void ) {
ChannelID = 1;
}
DataSet ds = new DataSet();
data.FillRSSChannels_Get(ds, ChannelID);
DataRow dr = ds.Tables(0).Rows(0);
ChannelTitle = FormatForXML(dr("Title").ToString());
ChannelLink = FormatForXML(dr("Link").ToString());
ChannelDescription = FormatForXML(dr("Description").ToString());
} catch (Exception ex) {
Response.Clear();
Response.Write(String.Format("<error>Channel {0}</error>", ex.Message));
Response.End();
}
try {
DataSet ds = new DataSet();
data.FillArticles_GetListForChannel(ds, ArticleCount, ChannelID);
DataView dv = new DataView();
dv.Table = ds.Tables(0);
dv.Sort = "DatePublished DESC";
rptRSS.DataSource = dv;
rptRSS.DataBind();
} catch (Exception ex) {
Response.Clear();
Response.Write(String.Format("<error>Articles {0}</error>", ex.Message));
Response.End();
}
data = null;
}

protected string FormatForXML(object 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
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...
2
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...
1
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...
6
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...
4
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
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....
1
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...
4
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
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...
2
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.