I recently suggested that it might be a nice idea to have a feed for the news on our corporate website. I pointed our webmaster to the RSS specification (which is a WTF
in itself - why would anyone willingly choose that stupid RFC822 date format when
there's a easily parseable ISO format available?) and he got to work.
This is what he came up with:
createfeed.asp
<html>
<head></head>
<% dim strXML
strXML = ""<?xml version=""1.0"" encoding=""utf-8""?>"
strXML = strXML & "<rss version=""2.0"">"
strXML = strXML & "<channel>"
strXML = strXML & "<title>News</title>"
strXML = strXML & "<description>Our newsfeed</description>"
dim RS
RS = DBGetTable("select * from news")
while not RS.eof
strXML = strXML &"<item><title>" & RS("title") & "</title>"
strXML = strXML & "<description>" & RS("text") & "</description>"
strXML = strXML & "</item>"
RS.moveNext
wend
RS.close
strXML = strXML & "</channel></rss>"
dim fs, file
set fs = CreateObject("Scripting.FileSystemObject")
set file = fs.CreateTextFile(Server.MapPath("rss.xml", true, false)
file.WriteLine(strXML)
file.Close
%>
<script>document.location.href = "rss.xml";</script>
</html>
(Typos and omissions mine, had to protect the guilty)
For non-coders: He builds a xml document (via the tried-and-trusted string concatenation, no less), writes it to the disk, and then redirects the client to that xml file (via javascript of course; a server-side Response.Redirect() would have been to easy).
The real WTF is that is actually worked.