Forum Moderators: open
My code is below:
Thanks
Graeme
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
<title>News</title>
<link>http://www.example.co.uk/news/</link>
<%
''Response.end
Response.Buffer = true
Response.ContentType = "text/xml"
Dim Connection
Dim Recordset
Dim SQL
Function ApplyXMLFormatting(strInput)
strInput = Replace(strInput,"&", "&")
strInput = Replace(strInput,"'", "'")
strInput = Replace(strInput,"""", """)
strInput = Replace(strInput, ">", ">")
strInput = Replace(strInput,"<","<")
ApplyXMLFormatting = strInput
End Function
Function FormatDateInXMLStyle(datDate)
FormatDateInXMLStyle = _
WeekdayName(Weekday(datDate), True) & ", " & _
Right("0" & Day(datDate), 2) & " " & _
MonthName(Month(datDate), True) & " " & _
Right("000" & Year(datDate), 4) '& " " & _
'Right("0" & Hour(datDate), 2) & ":" & _
'Right("0" & Minute(datDate), 2) & ":" & _
'Right("0" & Second(datDate), 2) & " GMT"
'e.g. Sat, 07 Sep 2002 09:42:31 GMT
End Function
SQL = "SELECT DISTINCT DocID, DocTitle, HTMLfile, PDFfile, DatePublished, Orderable, BriefDescription FROM vwSearch where SectionID=11 ORDER BY DatePublished DESC"
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
Connection.Open "provider=sqloledb;data source=www_alias;initial catalog=company;Integrated Security=SSPI"
Recordset.Open SQL,Connection
If Recordset.EOF Then
Response.Write("No records returned.")
End If
Do While NOT Recordset.Eof
%>
<item>
<title><%=ApplyXMLFormatting(Recordset("DocTitle"))%></title>
<%if Recordset("HTMLfile") <> "" then %>
<link>http://www.example.co.uk/news/files/<%=ApplyXMLFormatting(Recordset("HTMLfile"))%></link>
<%else%>
<link>http://www.example.co.uk/news/files/<%=ApplyXMLFormatting(Recordset("PDFfile"))%></link>
<%end if%>
<pubDate>
<%
=ApplyXMLFormatting(FormatDateInXMLStyle(Recordset("DatePublished")))
%>
</pubDate>
<description><%=ApplyXMLFormatting(Recordset("BriefDescription"))%></description></item><%
Recordset.MoveNext
Loop
Recordset.Close()
Set Recordset=nothing
Connection.Close
Set Connection=nothing
%></channel></rss>
[edited by: bill at 1:00 am (utc) on July 10, 2008]
[edit reason] Use example.com or example.co.uk for Examples [/edit]
If you don't want the date you shouldn't be selecting it for use from your table. Try changing the query to the following and see what you get:
SQL = "SELECT DISTINCT DocID, DocTitle, HTMLfile, PDFfile, Orderable, BriefDescription FROM vwSearch where SectionID=11"
the pubdate is specified according to RFC 822 which shows that the date is not optional:
[w3.org...]
<pubDate>
<%
dateString = Replace(Recordset("DatePublished"), "00:00:00", "")
Response.Write(ApplyXMLFormatting(FormatDateInXMLStyle(dateString)))
%>
</pubDate>
>> I don't really understand the link you sent me
He meant that you cannot get rid of "pubDate: from your RSS feed, which I've come to realize that you aren't, you just want to format the date/time differently since all the times are at 00:00:00. Try my changes above and see where that brings you.