/ Published in: ASP

Expand |
Embed | Plain Text
<% ' -------------------------------------------------------------------- Class asprss ' -------------------------------------------------------------------- ' 23.07.2007 | maurizio ' asprss v 0.1 ' Public rss_cs Public rss_sql Public channel_title Public channel_description Public channel_link Public channel_lastBuildDate Public item_title Public item_link Public item_pubdate Public item_description public ItemCount ' -------------------------------------------------------------------- Private Sub Class_Initialize() ' -------------------------------------------------------------------- response.CodePage = 65001 ' -> utf-8 response.CharSet = "utf-8" response.ContentType = "application/xml" ItemCount = 0 end Sub ' -------------------------------------------------------------------- Function gmt ( ddate ) ' -------------------------------------------------------------------- ' 23.07.2007 | maurizio ' data in formato gmt gmt = "" Session.LCID = 1033 gmt = gmt & FormatDateTime( ddate , vbLongDate) Session.LCID = 2057 gmt = gmt & " " & time() end function ' -------------------------------------------------------------------- Function create_item ( ) ' -------------------------------------------------------------------- ' 23.07.2007 | maurizio ' create_item = "" set cn_item = CreateObject("ADODB.Connection") cn_item.Open rss_cs set rs_item = CreateObject("ADODB.recordset") rs_item.Open rss_sql , cn_item , 0 , 1 , 1 nrow = 0 do while not rs_item.eof nrow = nrow + 1 create_item = create_item & "<item>" & vbcrlf create_item = create_item & "<title>" & rs_item(item_title) & "</title>" & vbcrlf create_item = create_item & "<link>" & server.htmlencode(rs_item(item_link)) & "</link>" & vbcrlf create_item = create_item & "<guid isPermaLink=""true"">" & server.htmlencode(rs_item(item_link)) & "</guid>" & vbcrlf create_item = create_item & "<pubDate>" & gmt(rs_item(item_pubdate)) & "</pubDate>" & vbcrlf create_item = create_item & "<description>" & rs_item(item_description) &"</description>" & vbcrlf create_item = create_item & "</item>" & vbcrlf if ItemCount > 0 and nrow => ItemCount then Exit Do else rs_item.movenext end if loop rs_item.Close cn_item.Close Set rs_item = Nothing Set cn_item = Nothing end function ' -------------------------------------------------------------------- Function create ( ) ' -------------------------------------------------------------------- ' 23.07.2007 | maurizio ' sRss = "<?xml version=""1.0"" encoding=""utf-8""?>" & vbcrlf sRss = sRss & "<rss version=""2.0"">" & vbcrlf 'sRss = sRss & "<rss version=""2.0"" xmlns:content=""http://purl.org/rss/1.0/modules/content/"" xmlns:wfw=""http://wellformedweb.org/CommentAPI/"" xmlns:dc=""http://purl.org/dc/elements/1.1/"" xmlns:geo=""http://www.w3.org/2003/01/geo/wgs84_pos#"" xmlns:creativeCommons=""http://backend.userland.com/creativeCommonsRssModule"" >" & vbcrlf sRss = sRss & "<channel>" & vbcrlf sRss = sRss & "<title>" & channel_title & "</title>" & vbcrlf sRss = sRss & "<description>" & channel_description & "</description>" & vbcrlf sRss = sRss & "<link>" & channel_link & "</link>" & vbcrlf sRss = sRss & "<lastBuildDate>" & channel_lastBuildDate & "</lastBuildDate>" & vbcrlf sRss = sRss & create_item() sRss = sRss & "</channel>" & vbcrlf sRss = sRss & "</rss>" & vbcrlf create = sRss end function end class ' esempio utilizzo ' set orss = new asprss orss.rss_cs = connectionstring orss.rss_sql = querysql orss.channel_title = "Video Mercurius" orss.channel_description = "il sito con i video delle scuole" orss.channel_link = "http://video.mercurius.it" orss.channel_lastBuildDate = date() orss.item_title = "title_video" orss.item_link = "link_video" orss.item_pubdate = "dateadd_video" orss.item_description = "descrio_video" orss.ItemCount = 5 response.write orss.create %>
You need to login to post a comment.