给你的asp+ac站点加rss功能

复制代码 代码如下:

<%
Response.ContentType="text/xml"
dim db,dbpath,conn
dim rs,SQL
db="shujuku/hotltcom.mdb"''''这里填写你的数据库地址
Set conn = Server.CreateObject("ADODB.Connection")
dbpath="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.Open dbpath
%>
'这里是xml的版本和语言声明

'以下相当于html的meta部分,包括标题.连接.语言.版权信息以及logo图标等
简单的快乐
http://siyizhu.com
简单的快乐
zh-cn
Copyright 2006 hotlt
hotlt@tom.com

简单的快乐 
http://siyizhu.com/logo.gif 
http://siyizhu.com/siyizhu's weblog
'以下是连接数据库数据表部分,top 15代表最新的15条,movie是数据表
<%
SQL="select top 15 * from movie order by id desc"
set rs=conn.execute(SQL)
if rs.Eof or rs.Bof then
response.write ""
end if
while not rs.Eof 
Title=rs("Title")'这里定义Title是标题,("Title")为字段名称
id=rs("id")'这里定义id是连接id ,("id")为字段名称
Time=rs("Time")'这里定义Time是时间 ,("Time")为字段名称
Content=replace(replace(left(rs("Content"),200),"<","<"),">",">")'这里的Content是内容的字段名称
'以下是rss输出
response.Write ""
Response.write ""&Title&"" '这里是输出标题
response.write "http://siyizhu.com/weblog/article.asp?ID="&id&"" '这里是输出链接,注意要用网址
response.write "siyizhu" '这里是输出作者,如果有字段可以调用字段
response.write ""&Time&"" '这里是时间
response.write ""'这里是输出简介,因为可能有代码.括起来,否则预览时会提示错误。
response.write "
"
rs.MoveNext 
wend 
set rs=nothing
conn.Close
set conn = nothing
%>


注意事项:其中要注意[CDATA*]>的使用,像是内容之类的输出尽量用"[CDATA[ * ]]>",
*为输出内容,应为内容可能为代码形式,如有空格或asp代码.否则可能会出错误. 

以上就是给你的asp+ac站点加rss功能的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » XML/RSS