把这个 Nuclear-Blog 6.0 的 Rss 订阅功能源码发出来,有需要的同学可以参考一下,源码很简单,可以自行升级一下……

Rss 订阅功能源码片段:

<!--#include file="Inc/Conn.asp"-->
<!--#include file="Inc/Anti-CC.asp"-->
<%
Function ShowRSS()                                                '判断输出 RSS 订阅
    If Cache = True Then                                          '如果是静态模式
        Dim P, Tmp
        P = CachePath & "Content_RSS.html"
        If CheckCache(P) = True Then                              '如果缓存文件存在
            Response.Write Fso.OpenTextFile(P, 1, False).Readall  '直接输出缓存
        Else
            Tmp = MakeRSS                                         '生成新的缓存文件
            Fso.OpenTextFile(P, 2, True).WriteLine Tmp
            Response.Write Tmp
        End If
    Else
        Response.Write MakeRSS
    End If
End Function

Function MakeRSS()                                                '输出 RSS 订阅
    'RSS 教程:http://www.w3school.com.cn/rss/index.asp
    ReadSet                                                       '读取配置
    Dim Tmp
    Tmp = "<?xml version=""1.0"" encoding=""gb2312"" ?>" & vbCrLf & _
          "<rss version=""2.0"">" & vbCrLf & _
          "<channel>" & vbCrLf
    Tmp = Tmp & "<title>" & Server.HtmlEncode(My_Name) & "</title>" & vbCrLf    '网站名称
    Tmp = Tmp & "<link>http://" & My_Url & "/</link>" & vbCrLf    '网站地址
    Tmp = Tmp & "<description>" & Server.HtmlEncode(My_Description) & "</description>" & vbCrLf '网站描述信息
    Tmp = Tmp & "<generator>Nuclear-Blog v6.0</generator>" & vbCrLf             '生成该 RSS feed 的程序名称
    Tmp = Tmp & "<language>zh-cn</language>" & vbCrLf             '语言
    Tmp = Tmp & "<copyright>RSS Feed For " & Server.HtmlEncode(My_Name) & "</copyright>" & vbCrLf '版权信息
    Sql = "select top 100 * from Content order by id desc"        '获取最新的100篇文章
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataPath
        Rs.Open Sql, Conn, 1, 3
            If Rs.RecordCount <= 0 Then ErrorInfo
            Rs.MoveFirst
            Dim I
            While Not Rs.EOF
                Tmp = Tmp & "<item>" & vbCrLf
                Tmp = Tmp & "<title>" & Server.HtmlEncode(Rs("标题")) & "</title>" & vbCrLf '标题
                Tmp = Tmp & "<link>http://" & My_Url & "/?" & P_A & "=" & Rs("ID") & "</link>" & vbCrLf '链接地址
                Tmp = Tmp & "<description>" & _
                      Server.HtmlEncode(IIf(Rs("描述") <> "", Rs("描述"), Left(Rs("内容"), 300))) & _
                      "</description>" & vbCrLf                   '内容
                Tmp = Tmp & "<author>" & Server.HtmlEncode(Replace(Rs("作者"), "{默认作者}", My_Author)) & "</author>" & vbCrLf '作者
                Tmp = Tmp & "<category>默认分类</category>" & vbCrLf            '分类
                Tmp = Tmp & "<pubDate>" & Rs("时间") & "</pubDate>" & vbCrLf    '发布时间
                Tmp = Tmp & "</item>" & vbCrLf
                Rs.MoveNext
            Wend
        Rs.Close
    Conn.Close
    Tmp = Tmp & "</channel>" & vbCrLf & "</rss>"
    MakeRSS = Tmp
End Function
%>

注释都写得很清楚,自己看看吧……

RSS 输出其实很简单,核心功能只有这一段:

Dim Tmp
Tmp = "<?xml version=""1.0"" encoding=""gb2312"" ?>" & vbCrLf & _
      "<rss version=""2.0"">" & vbCrLf & _
      "<channel>" & vbCrLf
Tmp = Tmp & "<title>" & Server.HtmlEncode(My_Name) & "</title>" & vbCrLf    '网站名称
Tmp = Tmp & "<link>http://" & My_Url & "/</link>" & vbCrLf    '网站地址
Tmp = Tmp & "<description>" & Server.HtmlEncode(My_Description) & "</description>" & vbCrLf '网站描述信息
Tmp = Tmp & "<generator>Nuclear-Blog v6.0</generator>" & vbCrLf             '生成该 RSS feed 的程序名称
Tmp = Tmp & "<language>zh-cn</language>" & vbCrLf             '语言
Tmp = Tmp & "<copyright>RSS Feed For " & Server.HtmlEncode(My_Name) & "</copyright>" & vbCrLf '版权信息
Sql = "select top 100 * from Content order by id desc"        '获取最新的100篇文章
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataPath
    Rs.Open Sql, Conn, 1, 3
        If Rs.RecordCount <= 0 Then ErrorInfo
        Rs.MoveFirst
        Dim I
        While Not Rs.EOF
            Tmp = Tmp & "<item>" & vbCrLf
            Tmp = Tmp & "<title>" & Server.HtmlEncode(Rs("标题")) & "</title>" & vbCrLf '标题
            Tmp = Tmp & "<link>http://" & My_Url & "/?" & P_A & "=" & Rs("ID") & "</link>" & vbCrLf '链接地址
            Tmp = Tmp & "<description>" & _
                  Server.HtmlEncode(IIf(Rs("描述") <> "", Rs("描述"), Left(Rs("内容"), 300))) & _
                  "</description>" & vbCrLf                   '内容
            Tmp = Tmp & "<author>" & Server.HtmlEncode(Replace(Rs("作者"), "{默认作者}", My_Author)) & "</author>" & vbCrLf '作者
            Tmp = Tmp & "<category>默认分类</category>" & vbCrLf            '分类
            Tmp = Tmp & "<pubDate>" & Rs("时间") & "</pubDate>" & vbCrLf    '发布时间
            Tmp = Tmp & "</item>" & vbCrLf
            Rs.MoveNext
        Wend
    Rs.Close
Conn.Close
Tmp = Tmp & "</channel>" & vbCrLf & "</rss>"
MakeRSS = Tmp