By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,212 Members | 2,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,212 IT Pros & Developers. It's quick & easy.

RSS feed <> sql server <> aspx <> xml <> blog

P: n/a
I have been researching articles on google on how to create a simple RSS
feed that sucks <title><blurb><link><date> out of a sql server 2000 database
via an aspx page.

I know it has to be pushed into a <xml> document but not sure which
direction to take.

Is there perhaps a starter document which uses sql server as the data source
I can tap into.

I am a newbie to aspx but I it appears there is a lot of inbuilt support for
this application and I don't wish to go down to many wrong paths or reinvent
the wheel.

Any advice appreciated!

Jason

ps: It appears that <rss> is tied in heavily with <blogs> these days....is
anyone come up with a combined solution?
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Here's the meat of the the rss.aspx that I use for blogabond.com. As
you can see, it's just a single repeater dumping out XML instead of
HTML. Couldn't be much simpler, though you'll need to remember to set
the ContentType on the server:

Page.Response.ContentType = "text/xml";

<?xml version="1.0" ?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
<channel>
<title>Blogabond.com - Livin' large in the third world</title>
<link>http://www.blogabond.com/</link>
<description>Travel journals and photo blogs from world travellers.
Maps, research and resources for the aspiring vagabond.</description>
<dc:language>en-US</dc:language>
<dc:creator></dc:creator>
<copyright>Copyright 2005, Blogabond.com</copyright>
<sy:updatePeriod>daily</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updateBase>1</sy:updateBase>
<asp:Repeater ID="rptComments" Runat=server>
<ItemTemplate>
<item>
<title><%# DataBinder.Eval(Container.DataItem,
"CommentTitle")%></title>
<description><![CDATA[<%# GetDescription(
DataBinder.Eval(Container.DataItem, "CommentText"),
DataBinder.Eval(Container.DataItem, "UserID") )%>]]></description>
<author><%# GetAuthorName( DataBinder.Eval(Container.DataItem,
"UserID") )%></author>
<category><%# GetLocationName( DataBinder.Eval(Container.DataItem,
"LocationID") )%></category>
<pubDate><%# GetPubDate( DataBinder.Eval(Container.DataItem,
"CommentDate") )%></pubDate>
<link>http://www.blogabond.com/TripView.aspx?tripID=<%#
DataBinder.Eval(Container.DataItem, "TripID")%></link>
<guid
isPermaLink="true">http://www.blogabond.com/CommentView.aspx?commentID=<%#
DataBinder.Eval(Container.DataItem, "CommentID")%></guid>
<slash:comments>0</slash:comments>
</item>
</ItemTemplate>
</asp:Repeater>
</channel>
</rss>

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

Nov 19 '05 #2

P: n/a
Dude, awesome - its been a long time since anyone has posted a full set of
example code for an inept <newbie /> such as myself. :)) Thanks!!

My first stupid question:

I sucked your code into aspx container page in web matrix (free) and tried
executing and obviously it generates a compile error with regards the
content type.

How do I actually insert the content type onto the page below?

I have done some searches on 'content type examples text/xml'.

I pick up a compilation error when I add this to the page:

<%Page ContentType="Text/Xml">

What am I doing wrong?

Nov 19 '05 #3

P: n/a
That needs to live on the codebehind (or possibly in a <script
runat=server> if you're not using codebehinds). Here is a small chunk
of mine. Obviously you'll need to generate your own dataset to bind
the repeater, and you'll need to write your own helper functions to
format dates and HtmlEntityEncode strings:

protected Repeater rptComments;

private void Page_Load(object sender, System.EventArgs e)
{
Page.Response.ContentType = "text/xml";

DataView dv = TripReportComment.List().Tables[0].DefaultView;
dv.Sort = Comment.Columns.CommentDate + " desc";

rptComments.DataSource = dv;
rptComments.DataBind();

}

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.