<%@ CODEPAGE=65001 %> <% ''時間轉換函數 Function return_RFC822_Date(byVal myDate, byVal TimeZone) Dim myDay, myDays, myMonth, myYear Dim myHours, myMinutes, mySeconds myDate = CDate(myDate) myDay = EnWeekDayName(myDate) myDays = Right("00" & Day(myDate),2) myMonth = EnMonthName(myDate) myYear = Year(myDate) myHours = Right("00" & Hour(myDate),2) myMinutes = Right("00" & Minute(myDate),2) mySeconds = Right("00" & Second(myDate),2) return_RFC822_Date = myDay&", "& _ myDays&" "& _ myMonth&" "& _ myYear&" "& _ myHours&":"& _ myMinutes&":"& _ mySeconds&" "& _ " " & TimeZone End Function ''星期轉換函數 Function EnWeekDayName(InputDate) Dim Result Select Case WeekDay(InputDate,1) Case 1:Result="Sun" Case 2:Result="Mon" Case 3:Result="Tue" Case 4:Result="Wed" Case 5:Result="Thu" Case 6:Result="Fri" Case 7:Result="Sat" End Select EnWeekDayName = Result End Function ''月份轉換函數 Function EnMonthName(InputDate) Dim Result Select Case Month(InputDate) Case 1:Result="Jan" Case 2:Result="Feb" Case 3:Result="Mar" Case 4:Result="Apr" Case 5:Result="May" Case 6:Result="Jun" Case 7:Result="Jul" Case 8:Result="Aug" Case 9:Result="Sep" Case 10:Result="Oct" Case 11:Result="Nov" Case 12:Result="Dec" End Select EnMonthName = Result End Function %> <% ''獲取當前域名,其中rss.asp為伱的文件名 sql="select top 50 * from [article] where view_yes=1 order by [time] desc" ''根據自己實際修改 set rs=server.createobject("adodb.recordset") rs.open sql,cn,1,1 response.contenttype="text/xml" XMLContent=XMLContent&"" & vbcrlf XMLContent=XMLContent&"" & vbcrlf XMLContent=XMLContent&"" & vbcrlf XMLContent=XMLContent&"" & vbcrlf XMLContent=XMLContent&" "& web_name & " 的最新動态 " & vbcrlf XMLContent=XMLContent&"" & web_url & "" & vbcrlf XMLContent=XMLContent&"zh-cn" & vbcrlf XMLContent=XMLContent&"RSS Feed By www.huiguer.com" & vbcrlf while not rs.eof set rsc=server.createobject("adodb.recordset") sqlc="select [name] from [category] where id="&rs("cid") rsc.open sqlc,cn,1,1 if not rsc.eof then CategoryName=rsc("name") end if rsc.close set rsc=nothing select case rs("ArticleType") case 1 Content_FolderName=Article_FolderName case 2 Content_FolderName=Product_FolderName end select XMLContent=XMLContent&"" & vbcrlf XMLContent=XMLContent&" <![CDATA[" & rs("title") & "]]> " & vbcrlf XMLContent=XMLContent&""&web_url&"/"&Content_FolderName&"/"& rs("file_path") &"" & vbcrlf XMLContent=XMLContent&"" & vbcrlf XMLContent=XMLContent&"" & return_RFC822_Date(rs("time"),"08:00") & "" & vbcrlf XMLContent=XMLContent&""&web_name&"" & vbcrlf XMLContent=XMLContent&""&CategoryName&"" & vbcrlf XMLContent=XMLContent&"" & vbcrlf rs.movenext wend XMLContent=XMLContent&"" & vbcrlf XMLContent=XMLContent&"" & vbcrlf rs.close set rs=nothing ''關閉數據庫 cn.close set cn=nothing %> <% '讀取模闆 '****************************************** '功能:生成UTF-8文件 '參數:File_name 文件名 '參數:File_path 生成文件所在相對目錄 '參數:content 寫入内容 '****************************************** sub Generation_File(File_name,File_path,content) mappath = "/"&File_path&"/"&File_name Set objStream = Server.CreateObject("ADODB.Stream") With objStream .Open .Charset = "utf-8" .Position = objStream.Size .WriteText=XMLContent .SaveToFile server.mappath(mappath),2 .Close End With Set objStream = Nothing end sub call Generation_File("Feed.xml","rss",XMLContent) '在xml目錄下生成編碼為utf-8的Feex.xml文件 response.write XMLContent %>