I stored HTML into a database for describing upcoming shows/events, but RSS doesn’t like HTML tags. So here’s my solution;
001 <?xml version="1.0" encoding="UTF-8"?>
002 <rss version="2.0">
003 <channel>
004 <title>Grandstand Sales, Inc.</title>
005 <link>http://www.GrandstandSales.com/</link>
006 <description>Grandstand Sales, Inc.</description>
007 <language>en-us</language>
008 <pubDate>Wed, 06 Jun 2007 12:14:00 EST</pubDate>
009 <lastBuildDate>Wed, 06 Jun 2007 12:14:00 EST</lastBuildDate>
010 <docs>http://www.GrandstandSales.com/GS/feed.aspx</docs>
011 <generator>GrandstandSalesGen</generator>
012 <managingEditor>jcook@kimbersinc.com</managingEditor>
013 <webMaster>jcook@kimbersinc.com</webMaster>
014
015 <asp:repeater id="Repeater1" runat="server" datasourceid="AccessDataSource1">
016 <ItemTemplate>
017 <item>
018 <title><%# Repl(Eval("ActName"))%> <%# Repl(Eval("ActGuest"))%></title>
019 <link>http://www.grandstandsales.com/gs/Detail.aspx?id=<%#Eval("ID") %></link>
020 <description>
021 <%#Repl(Eval("ActStart"))%> -
022 <%#Repl(Eval("ActDesc"))%>
023 </description>
024 <pubDate><%#dformat(Eval("dts"))%></pubDate>
025 <guid>http://www.grandstandsales.com/gs/Detail.aspx?id=<%#Eval("ID") %></guid>
026 </item>
027 </ItemTemplate>
028 </asp:repeater>
029
030 </channel>
031 </rss>
032
033 <asp:accessdatasource id="AccessDataSource1" runat="server" datafile="~/App_Data/grandstand.mdb"
034 selectcommand="SELECT * FROM [Acts] WHERE ([OrderID] <> ?) ORDER BY [OrderID]">
035 <SelectParameters>
036 <asp:Parameter Type="Int32" DefaultValue="0" Name="OrderID"></asp:Parameter>
037 </SelectParameters>
038 </asp:accessdatasource>
039
040 <script runat="server">
041 Function Repl(ByVal str)
042 Dim s As String = str
043 s = Replace(s, " ", " ")
044 s = Server.HtmlEncode(s)
045 Return (s)
046 End Function
047
048 Function dformat(ByVal rawDate)
049 Dim rfc As String = ""
050 Dim dt As String = rawDate '6/9/2007 5:30:00 PM
051
052 Dim A, B, C, D, E, F, G, H As String
053 '(A)Wed, (B)09 (C)Jun (D)2007 (E)20:(F)30:(G)00 (H)GMT
054
055 Dim arrDT As Array = Split(dt, " ") Dim oDate As Date = arrDT(0) '6/9/2007
056 Dim oTime As DateTime = arrDT(1) + " " + arrDT(2) '5:30:00 PM
057
058 A = oDate.DayOfWeek 'Wed
059 Select Case A
060 Case 1
061 A = "Mon"
062 Case 2
063 A = "Tue"
064 Case 3
065 A = "Wed"
066 Case 4
067 A = "Thu"
068 Case 5
069 A = "Fri"
070 Case 6
071 A = "Sat"
072 Case 7
073 A = "Sun"
074 End Select
075 B = oDate.Day '09 (day)
076 If B < 10 Then
077 B = "0" + B
078 End If
079 C = oDate.Month 'Jun (month)
080 Select Case C
081 Case 1
082 C = "Jan"
083 Case 2
084 C = "Feb"
085 Case 3
086 C = "Mar"
087 Case 4
088 C = "Apr"
089 Case 5
090 C = "May"
091 Case 6
092 C = "Jun"
093 Case 7
094 C = "Jul"
095 Case 8
096 C = "Aug"
097 Case 9
098 C = "Sep"
099 Case 10
100 C = "Oct"
101 Case 11
102 C = "Nov"
103 Case 12
104 C = "Dec"
105 End Select
106 D = oDate.Year '2007 (year)
107 E = oTime.Hour + 4 '20 (hour)
108 F = oTime.Minute '30 (minute)
109 G = "00" '00 (second)
110 H = "GMT" 'GMT (zone)
111
112 rfc = A + ", " + B + " " + C + " " + D + " " + E + ":" + F + ":" + G + " " + H
113
114 Return (rfc)
115 End Function
116
117 </script>
Line 001: This HAS to be on the First Line
Lines 015 to 028: I used a simple Repeater Control for the Item tags
Line 024: Calls the dformat Function (Lines 048 – 117)
Line 033: The WHERE clause simply hides the inactive/past events
Line 018, 021, 022: Call the Repl Function (Lines 041 -046)
Line 044: Encodes the Description to fix problems with Ampersands and Double Quotes
Line 048: This Function takes an Access DateTime Format and spits out an RFC-822 happy Format assuming an Eastern Time Zone (Line 109)