既然 RSS 是一种 XML 格式的文档,那么我们就应当可以对后台数据库中的数据按照条件进行筛选、组织,然后通过 ASP 生成 XML 格式的数据流,最后发送到客户端进行浏览。
数据的选取、汇集是 Asp 的拿手好戏,关键在于怎么生成 XML 格式的数据流。其实 Asp 也已经有自己的解决办法,就是在写数据前对 response 对象的 ContentType 属性进行定义。如果 response.ContentType 的取值为 "text/xml",就会向浏览者发送 XML 格式的数据流。
sSQL="select top 15 * from news order by sortid desc" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sSQL, s_Conn, 1, 1 if not (rs.eof and rs.bof) then do while not rs.eof response.write "<item>" & sCrLf response.write "<title> " & rs("f_topic") & " </title>" & sCrLf response.write "<link> " & "http://www.1234.com/_news/show_a_new.asp?autoid=" &