Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

RSS feed in ASP script

0.00/5 (No votes)
12 Jan 2005 1  
Very simple RSS feed script in ASP

Introduction

very simple

edit your own SQL exec yourself in this code

by Zion,  udanax@msn.com

sample : http://localhost/xrss.asp?FeedID=ifm_id

 


<?xml version="1.0" encoding="EUC-KR" ?>
<%
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
2004 code by udanax.msn.com
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim FeedID,Conn,rs,SQL,rs2, tt, cc, rr
FeedID = Request("FeedID")

'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
set Conn = Server.CreateObject("ADODB.connection")
Conn.Open gsInfoMailConnStr
SQL = "select top 1 b.sendpage_id, a.ifm_title, a.ifm_intro, a.ifm_id from ifm_info"
SQL += "a inner join ifm_sendpage_info b on a.ifm_id = b.ifm_id inner join ifm_sendpage_contents_info c on b.sendpage_id = c.sendpage_id"
SQL += "where a.ifm_id = '"&FeedID&"'"

set rs2 = Conn.Execute(SQL)
tt = rs2("ifm_title")
cc = rs2("ifm_intro")
rr = rs2("ifm_id")
rs2.close
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Response.ContentType = "text/xml"


Set xmlPars = Server.CreateObject("Msxml2.DOMDocument")
Set rss = xmlPars.CreateElement("rss")
rss.setAttribute "version", "2.0"
rss.setAttribute "xmlns:dc", "http://purl.org/dc/elements/1.1/"
rss.setAttribute "xmlns:sy", "http://purl.org/rss/1.0/modules/syndication/"
rss.setAttribute "xmlns:admin", "http://webns.net/mvcb/"
rss.setAttribute "xmlns:rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlPars.AppendChild(rss)
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''channel set start@
Set Channel = xmlPars.CreateElement("channel")
rss.AppendChild(Channel)

Set title = xmlPars.CreateElement("title")
Channel.AppendChild(title)
Channel.childnodes(0).text = tt

Set channel_link = xmlPars.CreateElement("link")
Channel.AppendChild(channel_link)
Channel.childnodes(1).text = "http://localhost/?ifm_id">http://localhost/?ifm_id=" & rr

Set description = xmlPars.CreateElement("description")
Channel.AppendChild(description)
Channel.childnodes(2).text = cc

Set language = "xmlPars.CreateElement(""dc:language")
Channel.AppendChild(language)
Channel.childnodes(3).text = "ko"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''db query
SQL = "select top 8 b.sendpage_id, a.ifm_title, a.ifm_intro, a.ifm_id, b.sendpage_title, a.user_id, a.chat_id, c.sendpage_contents, b.regdate"
SQL += "from ifm_info a inner join ifm_sendpage_info b on a.ifm_id = b.ifm_id inner join ifm_sendpage_contents_info c on b.sendpage_id = c.sendpage_id"
SQL += "where a.ifm_id = '"&FeedID&"' order by regdate desc"
set rs = Conn.Execute(SQL)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''loop
Do until rs.EOF

Set item = xmlPars.CreateElement("item")
Channel.AppendChild(item)

set title = xmlPars.CreateElement("title")
set link = xmlPars.CreateElement("link")
set description = xmlPars.CreateElement("description")
set dcdate = xmlPars.CreateElement("dc:date")
set dcsubject = xmlPars.CreateElement("dc:author")

item.AppendChild(title)
item.AppendChild(link)
item.AppendChild(description)
item.AppendChild(dcdate)
item.AppendChild(dcsubject)

item.childnodes(0).text = rs("sendpage_title")
item.childnodes(1).text = "http://localhost/?ifm_id="&rr&"&sendpage_id=" & rs("sendpage_id")
item.childnodes(2).text = rs("sendpage_contents")
item.childnodes(3).text = rs("regdate")
item.childnodes(4).text = rs("chat_id")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rs.movenext
loop

Response.Write xmlPars.xml
rs.close
set rs = nothing
Set xmlPars = nothing
%>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here