Books & Music
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
News & Politics
Religion & Spirituality
Travel & Culture
TV & Movies
Coding a RSS Feed - Body
It is very easy to use ASP to create a dynamic RSS feed that updates whenever you add fresh content to your site. This page helps you get the body - or core content - part of the RSS file set.
First, make sure you've set up a RSS reader to test your feed, and that you've read about the basics and printed out the sample. Those will be important so that you can test your output. Make sure you've already put in the header / top part of your RSS file, the standard top that would go on most any RSS feed you created.
Now we're at the section of the RSS file that actually contains the changing news announcement, blog updates, whatever it is you are telling people about. Let's say for the sake of argument that you have "articles" and you want to always tell people what your 3 latest articles are. Here's the code block you would use. Note that you have to strip out strange quotes and ampersands in order for XML to work properly. XML works with basic letters and numbers ONLY. It chokes on special characters. Ampersands must be escaped as &
Set FeatSite = Server.CreateObject ("ADODB.Recordset")
SQLText = "SELECT art_id, art_title, art_date, art_desc " & _
"from articles where art_date <= '" & Now() & "' " & _
"order by art_date DESC"
FeatSite.Open SQLText, strConnect, adOpenForwardOnly, adLockReadOnly, adCmdText
FeatCt = 1
do while not FeatSite.EOF and FeatCt < 4
ArtDesc = Replace(FeatSite("art_desc"), chr(180), "'")
ArtDesc = Replace(ArtDesc, "´", "'")
ArtDesc = Replace(ArtDesc, "&", "&")
ArtTitle = Replace(FeatSite("art_Title"), chr(180), "'")
ArtTitle = Replace(ArtTitle, "´", "'")
ArtTitle = Replace(ArtTitle, "&", "&")
ArtDate = FeatSite("art_date")
ArtHour = Hour(ArtDate)
if ArtHour < 10 then ArtHour = "0" & ArtHour
ArtMin = Minute(ArtDate)
if ArtMin < 10 then ArtMin = "0" & ArtMin
ArtSec = Second(ArtDate)
if ArtSec < 10 then ArtSec = "0" & ArtSec
ArtDateT = WeekdayName(Weekday(ArtDate), TRUE) & ", " & Day(ArtDate) & " " & _
MonthName(Month(ArtDate), TRUE) & " " & Year(ArtDate) & " " & _
ArtHour & ":" & ArtMin & ":" & ArtSec & " EST"
FeatCt = FeatCt + 1
set FeatSite = Nothing
That's it! Put that RSS file onto your server and make sure you update IIS so that it knows to handle files with an RSS extension as ASP files. Now you should be able to put the URL of that RSS file into your RSS reader, and get the updates!
RSS Feed - Header Part
Basics of a RSS Feed
RSS Feed Sample
Basic Setup of an RSS ASP File
| Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map
Content copyright © 2018 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact Lisa Shea for details.
Website copyright © 2018 Minerva WebWorks LLC. All rights reserved.