spacer
spacerLokken Logo
spacerLokken Binary Logo
spacer
spacer
spacer
spacer spacer spacer spacer
RSS Reader
Language:   Server Sided ASP - JavaScript
Author:   Jon Lokken
Date:   4-8-2005

Description:  
Get and RSS feed using Microsoft's Msxml2 dll.  This functions takes in the path of the rss feed an xsl styesheet and a place to cache the file.

<%@ LANGUAGE="JavaScript" %>
<% Response.buffer=true %>
<%

/*
* Get an RSS feed
* Author: Jon Lokken-4.8.2005
*/

objMyFSO= Server.CreateObject("Scripting.FileSystemObject");


function getRssFeed(pathOfPage, pathOfStyle, pathOfSave){
var styleFilePath = Server.MapPath(pathOfStyle);
var saveFilePath = Server.MapPath(pathOfSave);
var doesFileExist = objMyFSO.FileExists(styleFilePath);
var doesSaveFileExist = objMyFSO.FileExists(saveFilePath);
var saveFileHour = 0;

if(doesSaveFileExist){
var saveFile = objMyFSO.getFile(saveFilePath);
var saveFileDate = new Date(saveFile.DateLastModified);
saveFileHour = saveFileDate.getHours();
//Response.Write("saveFile Hour:"+saveFileHour+" Current Hour:"+hour);
}

if(doesFileExist){
var xmlObj = Server.CreateObject("Msxml2.DomDocument");
var xmlStyleObj = Server.CreateObject("Msxml2.DomDocument");

xmlObj.async = false;
if(!doesSaveFileExist || (hour - saveFileHour) != 0 ){
xmlObj.setProperty("ServerHTTPRequest", true);
xmlObj.load(pathOfPage);
xmlObj.save(saveFilePath);
} else {
xmlObj.load(saveFilePath);
}

xmlStyleObj.async = false;
xmlStyleObj.load(styleFilePath);

xmlObj.transformNodeToObject(xmlStyleObj, Response);

} else {
Response.Write("There was an error reading the rss feed.");
}
}

%>
 


Disclaimer:
Feel free to use this code I have written.  I only ask that you leave my name in the comments.  I take no responsibility for this code working, imply no warranty as to it's validity, and will not be held liable if you decide to try it.  I am only trying to help out others so they don't have to struggle with the same problems as me...

Associated Sites: Jon Lokken - http://www.jonlokken.com | Amy Lokken - http://www.amylokken.com | Isabel Lokken - http://www.isabellokken.com | Elizabeth Lokken - http://www.elizabethlokken.com | Lokken.us - http://www.lokken.us | Lokken.co - http://www.lokken.co | Lokken Consulting - http://www.lokkenconsulting.com
Author: Jon Lokken - http://www.lokken.net