Welcome to my ASP Code Website

Coding a RSS Feed - Header



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 top - or header - part of the RSS file set. This is going to be the same for pretty much any RSS feed you create.

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.

Now it's simply a matter of coding a file that is FILENAME.RSS that is set up to display your 3 latest articles or blog entries in proper RSS format.

First, the standard top area. You barely even need ASP for this part - just to put the current date into the appropriate spot.

<rss version="2.0">
<channel>
<title>YOURSITETITLE</title>
<link>YOURURLLINK</link>
<description>YOURDESCRIPTION</description>
<language>en-us</language>
<copyright>YOURCOPYRIGHT</copyright>

<%
CurrDate = Now()

CurrHour = Hour(CurrDate)
if CurrHour < 10 then CurrHour = "0" & CurrHour
CurrMin = Minute(CurrDate)
if CurrMin < 10 then CurrMin = "0" & CurrMin
CurrSec = Second(CurrDate)
if CurrSec < 10 then CurrSec = "0" & CurrSec

CurrDateT = WeekdayName(Weekday(CurrDate), TRUE) & ", " & Day(CurrDate) & " " & _
MonthName(Month(CurrDate), TRUE) & " " & Year(CurrDate) & " " & _
CurrHour & ":" & CurrMin & ":" & CurrSec & " EST"
%>
<lastBuildDate><%=CurrDateT%></lastBuildDate>
<ttl>240</ttl>
<image>
<url>YOURSITEIMAGEFILE</url>
<title>YOURSITENAME</title>
<link>YOURSITEURL</link>
</image>

-------------

Now it's time to code the meat of the RSS file, which we'll cover on a separate page to keep things easy to follow. This is in the SAME FILE - it's just explained in two parts.

ASP RSS Feed Code