<% Option Explicit Dim sql,rsnews,count,xmlrssfeed,rscache,tcheck,xmlstatus Response.Buffer=True xmlrssfeed = Request.QueryString("rssurl") if xmlrssfeed="" then xmlrssfeed="http://rss.news.yahoo.com/rss/world" %> <% Function getXML(sourceFile) dim styleFile dim xmlsource, xmlstyle, xmldoc styleFile = Server.MapPath("news.xsl") 'Check if Feed exists in cache: sql = "SELECT mynews_sites.url, mynews_sites.cacheInterval, mynews_sites.lastChecked, mynews_sites.xml FROM mynews_sites WHERE (((mynews_sites.url)='" & sourceFile& "'))" Set rscache = Server.CreateObject("ADODB.Recordset") rscache.Open sql, conn, 3, 3 if rscache.EOF then xmlstatus="none" else 'How long since cache was updated? tcheck=int((now()-rscache("lastchecked"))*24*60) if tcheck >= rscache("cacheInterval") then xmlstatus="update" end if end if 'Cache is out of date or cache does not exist. Get current from web. if xmlstatus="none" or xmlstatus="update" then Dim xmlhttp Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0") xmlhttp.Open "GET", sourceFile, false xmlhttp.Send if xmlhttp.status <>200 then %>HTTP Error: <%=xmlhttp.status%>
<% end if set xmlsource= xmlhttp.responseXML if xmlsource.xml = "" then xmlsource.loadxml(xmlhttp.ResponseText) end if xmlsource.setProperty "ServerHTTPRequest", True xmlsource.resolveExternals = false xmlsource.validateOnParse = false xmlsource.async = false if xmlsource.parseError.errorCode <> 0 and xmlhttp.status = 200 then%> XML Parse Error:
File Position: <%=xmlsource.parseError.filepos%>
Line: <%=xmlsource.parseError.line%>
Line Position: <%=xmlsource.parseError.linepos%>
Reason: <%=xmlsource.parseError.reason%>
Text: Line: <%=xmlsource.parseError.srctext%>
ErrorCode: <%=xmlsource.parseError.errorCode%>
URL: <%=xmlsource.parseError.URL%>
<% else if xmlstatus="update" then 'Now update database with current feed. rscache("xml")=xmlsource.xml rscache("lastchecked")=now() rscache.update end if end if else 'Get XML from Cache in Database. set xmlsource = Server.CreateObject("Microsoft.XMLDOM") xmlsource.loadxml(rscache("xml")) end if set xmlstyle = Server.CreateObject("Microsoft.XMLDOM") xmlstyle.load(styleFile) getXML = xmlsource.transformNode(xmlstyle) set xmlsource = nothing set xmlstyle = nothing End Function %> RSS NewsFeed

RSS News Feeds


Feeds:
<% sql="SELECT mynews_sites.site AS rss, mynews_sites.url AS feed FROM mynews_sites ORDER BY mynews_sites.site" Set rsnews = Server.CreateObject("ADODB.Recordset") rsnews.Open sql, conn, 3, 3 rsnews.Movefirst for count = 1 to 30 %> "><%=rsnews("rss")%>
<% rsnews.Movenext if rsnews.EOF then exit for end if next %>

Some of these feeds were brought to you courtesy of:
MyRss

<%=getXML(xmlrssfeed)%> 

© Jaidev Vasudevan 2004 <% rsnews.close set rsnews = nothing conn.close set conn = nothing %>