RSS的範例


Tamako 發表



如何在ASP中使用RSS

找了很久,終於找到RSS的範例了~
請大家參考看看~

ps:粗體字請修改

<%@Language="VBScript" Codepage="65001"%>
<%
Set XMLDOM=Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
XMLDOM.appendChild(XMLDOM.createElement("rss"))
XMLDOM.documentElement.attributes.setNamedItem(XMLDOM.createNode(2,"version","")).text="2.0"
Set node=XMLDOM.documentElement.appendChild(XMLDOM.createNode(1,"channel",""))

node.appendChild(XMLDOM.createNode(1,"title","")).text="標題"
node.appendChild(XMLDOM.createNode(1,"link","")).text="網址"
node.appendChild(XMLDOM.createNode(1,"language","")).text="zh-tw"
node.appendChild(XMLDOM.createNode(1,"description","")).text="描述"
node.appendChild(XMLDOM.createNode(1,"copyright","")).text="版權宣告"
node.appendChild(XMLDOM.createNode(1,"generator","")).text="Tamako"
node.appendChild(XMLDOM.createNode(1,"webMaster","")).text="i@tamako.us"
%>
<!--#include file="db.asp"-->   ' 這婼苭N入您的資料庫
<%
Set rs=conn.Execute("SELECT TOP 5 * FROM Indy ORDER BY Release DESC")
Do While Not rs.Eof
Set Cnode=node.appendChild(XMLDOM.createNode(1,"item",""))
Cnode.appendChild(XMLDOM.createNode(1,"title","")).text= rs("title") &""
Cnode.appendChild(XMLDOM.createNode(1,"url","")).text= rs("title") &""
Cnode.appendChild(XMLDOM.createNode(1,"link","")).text= "網址/show.asp? i="&rs("Item")
Cnode.appendChild(XMLDOM.createNode(1,"description","")).text= rs ("Intro") &""
rs.Movenext
Loop
set rs = nothing
conn.close
set conn = nothing

Response.Clear
Response.CharSet="UTF-8"
Response.ContentType="text/xml"
Response.Write ""&vbNewLine
Response.Write XMLDOM.xml
Set XMLDOM=Nothing
%>

  

最後更新日期: 6/26/2006 5:11:28 PM