"Billy Barth" <bj******@gmail.comwrote in message
news:Xn*****************************@66.150.105.47 ...
>I would like to create a RSS feed from my Access Database.
I have an Access table for news which has the article title, date, and
story in it. What I would like to do is pull the data from there into an
xml file to create the RSS feed, so when users upload a news story it
automatically updates in the xml file. Can this be done with asp? and
where
should I look for more information. Thanks, This is a great group.
Was used to pull all stories entered within the last 30 days. Obviously you
can alter the date range, regional settings (eg language, date format, time)
and links according to your needs. The result validates against RSS 2.0.
<%
function tidyxml(text)
text = replace(text,Chr(180),"'")
text = replace(text,"&","&")
text = replace(text,"'","'")
text = replace(text,"'","'")
text = replace(text,""","""")
text = replace(text,""","""")
text = replace(text,"<br>","")
text = replace(text,"-","-")
text = replace(text,"<","<")
text = replace(text,">",">")
tidyxml = text
End function
thedate = Month(CurrDate) & "/" & Day(CurrDate) & "/" & Year(CurrDate)
if Month(CurrDate) = 1 then
thepreviousdate = "12/" & Day(CurrDate) & "/" & (Year(CurrDate)-1)
else
thepreviousdate = (Month(CurrDate)-1) & "/" & Day(CurrDate) & "/" &
Year(CurrDate)
end if
newsSQL = "SELECT StoryID,Headline, Description, DateEntered FROM Stories "
& _
WHERE DateEntered BETWEEN " & _
"#" & thedate & " 23:59:59# And #" & thepreviousdate & " 0:0:1#;"
set conn = server.createobject("ADODB.Connection")
conn.Open connectionstring
set rsNews = conn.execute(newsSQL)
If Not rs.EOF Then
arrNews = rsNews.GetRows()
rsNews.close : set rsNews = nothing
conn.close : set conn = nothing
filename = "rss/rss.xml"
set fso = createobject("scripting.filesystemobject")
set xmlfile = fso.createtextfile(server.mappath(filename),true)
xmlfile.writeline("<?xml version=""1.0"" encoding=""iso-8859-1""?>")
xmlfile.writeline("<rss version=""2.0"">")
xmlfile.writeline("<channel>")
xmlfile.writeline("<title>Title</title>")
xmlfile.writeline("<link>Url</link>")
xmlfile.writeline("<description>Description</description>")
xmlfile.writeline("<language>en-gb</language>")
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 & " GMT"
xmlfile.writeline("<lastBuildDate>" & CurrDateT & "</lastBuildDate>")
xmlfile.writeline("<copyright>Copyright: (C) " & Year(Now()) & "
CopyrightOwner</copyright>")
for i = 0 to ubound(arrNews,2)
PubDate = arrNews(3,i)
PubHour = Hour(PubDate)
if PubHour < 10 then PubHour = "0" & PubHour
PubMin = Minute(PubDate)
if PubMin < 10 then PubMin = "0" & PubMin
PubSec = Second(PubDate)
if PubSec < 10 then PubSec = "0" & PubSec
PubDateT = WeekdayName(Weekday(PubDate), TRUE) & ", " & Day(PubDate) & " " &
_
MonthName(Month(PubDate), TRUE) & " " & Year(PubDate) & " " & _
PubHour & ":" & PubMin & ":" & PubSec & " GMT"
xmlfile.writeline("<item>")
xmlfile.writeline("<title>" & tidyxml(arrNews(1,i)) & "</title>")
xmlfile.writeline("<description>" & tidyxml(arrNews(2,i)) &
"</description>")
xmlfile.writeline("<link>URL/story.asp?id=" & arrNews(0,i) & "</link>")
xmlfile.writeline("<guid isPermaLink=""false"">URL/story.asp?id=" &
arrNews(0,i) & "</guid>")
xmlfile.writeline("<pubDate>" & PubDateT & "</pubDate>")
xmlfile.writeline("</item>")
next
xmlfile.writeline("</channel>")
xmlfile.writeline("</rss>")
set fso = nothing
Else
rs.close
End If
%>