asp生成rss代码

asp生成rss代码

保存为rss.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#Include file="conn.asp"-->
<%
Response.Charset = "gb2312"
Response.ContentType="text/xml"

Dim sql
    sql = "Select Top 5 n_id,n_title,n_content,n_time From [News] Order By n_time desc,n_id Desc"
Set rs = conn.Execute(sql)

Response.Write("<?xml version=""1.0"" encoding=""gb2312"" ?>")
Response.Write("<rss version=""2.0"">")
Response.Write("<channel>")
Response.Write("<title>jspok.com rss 测试</title>")
Response.Write("<link>http://zgc.net.ru/pm</link>")
Response.Write("<description>jspok.com rss 测试</description>")

Do While (rs.Eof = False)
    Response.Write("<item>")       
    Response.Write("<title><![CDATA["&rs("n_title")&"]]></title>")
    Response.Write("<link><![CDATA[http://zgc.net.ru/pm/shownews.asp?id="&rs("n_id")&"]]></link>")
    Response.Write("<description><![CDATA["&left(rs("n_content"),50)&"]]></description>")
    Response.Write("<author><![CDATA[admin]]></author>")
    Response.Write("<category><![CDATA[免费QQ绣]]></category>")
    Response.Write("<pubDate><![CDATA["&rs("n_time")&"]]></pubDate>")       
    Response.Write("</item>")
    rs.MoveNext()
Loop

Response.Write("</channel>")
Response.Write("</rss>")

%>

发表评论

电子邮件地址不会被公开。 必填项已用*标注