主頁 > 知識庫 > 給你的asp+ac站點加rss功能

給你的asp+ac站點加rss功能

熱門標簽:銀行業(yè)務 鐵路電話系統(tǒng) 網站文章發(fā)布 檢查注冊表項 智能手機 美圖手機 服務器配置 呼叫中心市場需求
復制代碼 代碼如下:

%
Response.ContentType="text/xml"
dim db,dbpath,conn
dim rs,SQL
db="shujuku/hotltcom.mdb"''''這里填寫你的數(shù)據(jù)庫地址
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">'這里是xml的版本和語言聲明
channel>
'以下相當于html的meta部分,包括標題.連接.語言.版權信息以及l(fā)ogo圖標等
title>簡單的快樂/title>
link>http://siyizhu.com/link>
Description>簡單的快樂/Description>
language>zh-cn/language>
copyright>Copyright 2006 hotlt/copyright>
webMaster>hotlt@tom.com/webMaster>
image>
title>簡單的快樂/title> 
url>http://siyizhu.com/logo.gif/url> 
link>http://siyizhu.com//link>description>siyizhu's weblog/description>/image>
'以下是連接數(shù)據(jù)庫數(shù)據(jù)表部分,top 15代表最新的15條,movie是數(shù)據(jù)表
%
SQL="select top 15 * from movie 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 
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 "item>"
Response.write "title>"Title"/title>" '這里是輸出標題
response.write "link>http://siyizhu.com/weblog/article.asp?ID="id"/link>" '這里是輸出鏈接,注意要用網址
response.write "author>siyizhu/author>" '這里是輸出作者,如果有字段可以調用字段
response.write "PubDate>"Time"/PubDate>" '這里是時間
response.write "description>![CDATA["Content"]]>/description>"'這里是輸出簡介,因為可能有代碼.括起來,否則預覽時會提示錯誤。
response.write "/item>"
rs.MoveNext 
wend 
set rs=nothing
conn.Close
set conn = nothing
%>
/channel>/rss>

注意事項:其中要注意[CDATA*]>的使用,像是內容之類的輸出盡量用"[CDATA[ * ]]>",
*為輸出內容,應為內容可能為代碼形式,如有空格或asp代碼.否則可能會出錯誤. 

標簽:新疆 滄州 沈陽 上海 河南 樂山 紅河 長治

巨人網絡通訊聲明:本文標題《給你的asp+ac站點加rss功能》,本文關鍵詞  ;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266