生成RSS文件

发布时间:2007-03-06 21:02:00 阅读:469次

<%
set conn=server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath("db1.mdb")
%>

<%
  XmlFileName="rss.xml"
  LineHead="<?xml version=""1.0"" encoding=""gb2312""?>" & vbcrlf
  LineHead=LineHead & "<rss version=""2.0"" xmlns:dc=""http://purl.org/dc/elements/1.1/"" "
  LineHead=LineHead & "xmlns:trackback=""http://madskills.com/public/xml/rss/module/trackback/"" "
  LineHead=LineHead & "xmlns:wfw=""http://wellformedweb.org/CommentAPI/"" "
  LineHead=LineHead & "xmlns:slash=""http://purl.org/rss/1.0/modules/slash/"" "
  LineHead=LineHead & "xmlns:content=""http://purl.org/rss/1.0/modules/content/"">"
  LineHead=LineHead & "<channel>" & vbcrlf
  LineHead=LineHead & "<title>rss</title>" & vbcrlf
  LineHead=LineHead & "<link>http://www.siyuroom.com/info/ListInfo.asp?id=1</link>" & vbcrlf
  LineHead=LineHead & "<description><![CDATA[风云]]></description>" & vbcrlf
  LineHead=LineHead & "<copyright>风</copyright>" & vbcrlf
  LineHead=LineHead & "<generator>云</generator>" & vbcrlf
  LineHead=LineHead & "<webMaster>test115@163.com</webMaster>" & vbcrlf
  

  Dim LineItem(10)
  Dim LineID(10)
  Dim LineTitle(10)
  Dim LineLink(10)
  Dim LineAuthor(10)
  Dim LinePubDate(10)
  Dim LineDescription(10)
  Dim LineReplyNum(10)
  Dim LineClickNum(10)
  Dim LineAuthorID(10)
  Dim LineEndItem(10)
  
  Dim iLine
  iLine=1
  strSql2="select *from forum"
  Set rs2=conn.execute(strSql2)
  
  Do Until rs2.eof
  
   LineItem(iLine)          ="<item>"
   LineID(iLine)            ="<ID>" & rs2("id") & "</ID>"
   LineTitle(iLine)         ="<title><![CDATA[" & rs2("topic") & "]]></title>"
   LineLink(iLine)          ="<link>http://www.siyuroom.com/forum/ShowPost.asp?id=" & rs2("id") & "</link>"
   LineAuthor(iLine)        ="<author><![CDATA[" & rs2("userhome") & "]]></author>"
   LinePubDate(iLine)   ="<pubDate>" & rs2("posttime") & "</pubDate>"
   LineDescription(iLine)   ="<description><![CDATA[" & rs2("topic") & "]]></description>"
   LineReplyNum(iLine)      ="<replyNum>" & rs2("replies") & "</replyNum>"
   LineClickNum(iLine)      ="<clickNum>" & rs2("views") & "</clickNum>"
   LineAuthorID(iLine)      ="<authorID>" & rs2("uid") & "</authorID>"
   LineEndItem(iLine)       ="</item>"

  iLine=iLine+1
  rs2.movenext
  Loop 
  LineBottom="</channel>" & vbcrlf
  lineBottom=lineBottom & "</rss>"
  
  FilePath=Server.MapPath(XmlFileName)
  Set fso=Server.CreateObject("Scripting.FileSystemObject")
  Set fout=fso.CreateTextFile(FilePath)
  fout.WriteLine LineHead
   For i=1 To iLine-1
   fout.WriteLine LineItem(i)
   fout.WriteLine LineID(i)
   fout.WriteLine LineTitle(i)
   fout.WriteLine LineLink(i)
   fout.WriteLine LineAuthor(i)
   fout.WriteLine LinePubDate(i)
   fout.WriteLine LineDescription(i)
   fout.WriteLine LineReplyNum(i)
   fout.WriteLine LineClickNum(i)
   fout.WriteLine LineAuthorID(i)
   fout.WriteLine LineEndItem(i)
  Next
  
  fout.WriteLine LineBottom

  response.write "已成功生成文档 <a href='" & XmlFileName & "' target=_blank>" & XmlFileName & "</a><br>"
%>

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:生成RSS文件 出自老鄢博客 | 欢迎分享