ASP κωδικός για την ανάγνωση RSS feeds... με σχετικές XSLT... (ελληνικά (Greek))

ASP κωδικός για την ανάγνωση RSS feeds... με σχετικές XSLT...

Tuesday, 11 May 2004

//

Less than a minute

Αν και θα το δημοσιεύσω αυτό...βασικά θα χρειαστεί μια RSS (ή οποιαδήποτε άλλη XML) τροφή από μια εξωτερική πηγή και θα το μετατρέψει χρησιμοποιώντας ένα συγκεκριμένο σενάριο XSLT (δοκιμάστε αυτό για ένα βασικό μετασχηματιστή RSS... rssTransform.xslt) Η χρήση είναι αρκετά απλή... για παράδειγμα:

Απάντηση.Write(getXML("http://weblogs.asp.net/mainfeed.aspx","../xslt/rssTransform.xslt,"120)

θα αναλύσει το ASP.NET weblogs κύρια τροφοδοσία...με 120 δευτερόλεπτα χρόνο κρυφής μνήμης


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 
Finding related posts...
logo

© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.