The following method for producing RSS feeds
using standard asp.net data components isn't a million miles away from others
documented, but I wanted to provide an easy quick start for any devs out there
who get the fateful brief "oh, before we put this live can you just add an RSS
feed of this data".
If you've done any reading then you'll know that RSS (Really Simple Syndication)
is based around a specific XML format that is well documented elsewhere. The key
to simple databound RSS is to use a standard page and standard controls, but
writing out XML rather than HTML markup.
To make the page work as a feed you need to do the following:
- Delete out all preentered content except
for the @Page directive.
- In the Page directive include the
attribute ContentType="text/xml".
- Include a standard datasource that will
output the data that you want to publish.
- Include an asp repeater with the
DataSourceID set to your datasource, and with the following content:
HeaderTemplate:
<rss
version="2.0">
<channel>
<title>FEED
NAME</title>
<link>URL
THAT THE FEED WILL BE PUBLISHED TO</link>
<description>DESCRIPTION
OF THE FEED</description>
FooterTemplate:
</channel>
</rss>
ItemTemplate:
<item>
<title><%#DataBinder.Eval(Container.DataItem,
"POST TITLE COLUMN")%></title>
<description><%#DataBinder.Eval(Container.DataItem,
"POST TEXT SUMMARY COLUMN")%></description>
<link>CLICK-THROUGH
URL</link>
<pubdate><%#DataBinder.Eval(Container.DataItem,
"ARTICLE TIMESTAMP COLUMN")%></pubdate>
</item>
That's all it takes - Enjoy :)