mostlylucid

scott galloway's personal blog...
posts - 906, comments - 722, trackbacks - 11

My Links

News

Archives

Post Categories

Misc. Coding

ASP code for reading RSS feeds...with associated XSLT...

Though I'd post this...basically it'll take an RSS (or other any XML) feed from an external source and transform it using a specified XSLT script (try this one for a basic RSS transformer... rssTransform.xslt) Usage is pretty simple...for example :
Response.Write(getXML("http://weblogs.asp.net/mainfeed.aspx","../xslt/rssTransform.xslt",120))
will parse the ASP.NET weblogs main feed...with a 120 second cache time
Function getXML(sourceFile,xsltFile,cacheTime) 
'On Error Resume Next
if((DateDiff("s",Application.Value(sourceFile + "_Expr"),Now())>cacheTime) Or len(Application.Value(sourceFile))=0) then
dim styleFile 
dim source, style 
styleFile = Server.MapPath(xsltFile)

Dim xmlhttp
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
xmlhttp.Open "GET", sourceFile, false
xmlhttp.Send

set source = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
source.async = false 
source.loadxml(xmlhttp.ResponseText) 
set style = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
style.async = false 
style.load(styleFile) 
outputHtml = source.transformNode(style) 
if(err.number = 0) then
Application.Lock
Application(sourceFile) = outputHtml
Application.Value(sourceFile + "_Expr") = now()
Application.UnLock
getXML = outputHtml
else
getXML = Application.Value(sourceFile)
end if

set source = nothing 
set style = nothing 
else
getXML = Application.Value(sourceFile)
end if
On Error Goto 0
End Function 

Print | posted on Wednesday, September 17, 2003 10:19 PM | Filed Under [ Random ]

Comments have been closed on this topic.

Powered by: