国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 擴(kuò)展 > RSS > 正文

給你的asp+ac站點(diǎn)加rss功能

2024-09-06 20:00:50
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
復(fù)制代碼 代碼如下:

<%
Response.ContentType="text/xml"
dim db,dbpath,conn
dim rs,SQL
db="shujuku/hotltcom.mdb"''''這里填寫你的數(shù)據(jù)庫(kù)地址
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的版本和語(yǔ)言聲明
<channel>
'以下相當(dāng)于html的meta部分,包括標(biāo)題.連接.語(yǔ)言.版權(quán)信息以及l(fā)ogo圖標(biāo)等
<title>簡(jiǎn)單的快樂(lè)</title>
<link>http://siyizhu.com</link>
<Description>簡(jiǎn)單的快樂(lè)</Description>
<language>zh-cn</language>
<copyright>Copyright 2006 hotlt</copyright>
<webMaster>hotlt@tom.com</webMaster>
<image>
<title>簡(jiǎn)單的快樂(lè)</title> 
<url>http://siyizhu.com/logo.gif</url> 
<link>http://siyizhu.com/</link><description>siyizhu's weblog</description></image>
'以下是連接數(shù)據(jù)庫(kù)數(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是標(biāo)題,("Title")為字段名稱
id=rs("id")'這里定義id是連接id ,("id")為字段名稱
Time=rs("Time")'這里定義Time是時(shí)間 ,("Time")為字段名稱
Content=replace(replace(left(rs("Content"),200),"<","<"),">",">")'這里的Content是內(nèi)容的字段名稱
'以下是rss輸出
response.Write "<item>"
Response.write "<title>"&Title&"</title>" '這里是輸出標(biāo)題
response.write "<link>http://siyizhu.com/weblog/article.asp?ID="&id&"</link>" '這里是輸出鏈接,注意要用網(wǎng)址
response.write "<author>siyizhu</author>" '這里是輸出作者,如果有字段可以調(diào)用字段
response.write "<PubDate>"&Time&"</PubDate>" '這里是時(shí)間
response.write "<description><![CDATA["&Content&"]]></description>"'這里是輸出簡(jiǎn)介,因?yàn)榭赡苡写a.括起來(lái),否則預(yù)覽時(shí)會(huì)提示錯(cuò)誤。
response.write "</item>"
rs.MoveNext 
wend 
set rs=nothing
conn.Close
set conn = nothing
%>
</channel></rss>

注意事項(xiàng):其中要注意[CDATA*]>的使用,像是內(nèi)容之類的輸出盡量用"[CDATA[ * ]]>",
*為輸出內(nèi)容,應(yīng)為內(nèi)容可能為代碼形式,如有空格或asp代碼.否則可能會(huì)出錯(cuò)誤. 
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 唐海县| 英吉沙县| 靖江市| 隆回县| 贵南县| 搜索| 红原县| 贺兰县| 三都| 岳阳县| 延川县| 阜宁县| 广昌县| 娄底市| 重庆市| 客服| 洛阳市| 屏东县| 京山县| 清新县| 夹江县| 长子县| 城固县| 石林| 行唐县| 寿宁县| 饶平县| 新密市| 镇巴县| 靖宇县| 光山县| 西充县| 金坛市| 万安县| 呼和浩特市| 达尔| 台南县| 天峻县| 金川县| 东阿县| 涟源市|