打造自己的RSS

类别:Asp 点击:0 评论:0 推荐:

       今天用asp写了一个自己网站的RSS,写了两看asp程序,本以为写个rrs很容易结果破费周折,下面把我的rss的代码贴出来供大家修改使用

<%
Response.ContentType="text/xml"
dim db,dbpath,conn
dim rs,SQL
db="db/#flsjfd8ulfs.asp"'数据库地址
Set conn = Server.CreateObject("ADODB.Connection")
dbpath="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.Open dbpath
%><?xml version="1.0" encoding="gb2312"?><rss version="2.0">
<channel>
<title>我的网站名称</title>
<link>http://www.myweb.com</link>
<description>网站描术</description>
<%
SQL="select top 10 * from news order by id desc"
set rs=conn.execute(SQL)
if rs.Eof or rs.Bof then
  response.write "<item></item>"
end if
while not rs.Eof
a=rs("title")
b=rs("author")
c=rs("times")
d=replace(replace(left(rs("content"),200),"<","&lt;"),">","&gt;")
    response.Write "<item>"
 response.write "<link>http://xyb.nuc.edu.cn/readnews.asp?id="&rs("id")&"</link>"
 Response.write "<title>"&a&"</title>"
 response.write "<creator>"&b&"</creator>"
 response.write "<PubDate>"&c&"</PubDate>"
  response.write "<description>"&d&"</description>"
 response.write "</item>"
 rs.MoveNext         
wend                 
set rs=nothing
conn.Close
set conn = nothing
%>
</channel></rss>


还有一些其它可选标签,大家可根据需要增减,具体RSS请在网上搜RSS规范查看

本文地址:http://com.8s8s.com/it/it8088.htm