# ASP-kod för att läsa RSS-flöden...med tillhörande XSLT...

<datetime class="hidden">2004-05-11T00:00</datetime>

<!-- category -- mostlylucidcouk, Imported, ASP.NET, XML -->
Även om jag skulle posta detta ... i grund och botten kommer det att ta en RSS (eller någon annan XML) feed från en extern källa och omvandla den med hjälp av en specificerad XSLT skript (försök detta för en grundläggande RSS-transformer... [rssTransform.xslt](/uploads/rssTransform.xslt))
Användning är ganska enkel ... till exempel :

Svar.Skriv(getXML("http://weblogs.asp.net/mainfeed.aspx","../xslt/rssTransform.xslt",120)

kommer att tolka ASP.NET webbloggar huvudflöde ... med en 120 andra cache tid

```

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 
```