<% option explicit %> <% 'constants const numItems = 5 dim endline, tab endline = chr(10) tab = chr(9) 'variables dim fileSystem 'the filesystem object dim objXML 'the xml object dim rssDir 'rss directory dim rssFile 'rss file dim xmlDir 'xml directory dim i 'loop counter dim rss 'the rss file handler dim currentDate 'for pubDate in output file 'to write into the output file dim title 'the xml item title dim category 'the xml item category dim link 'the xml item link dim description 'the xml item description dim pubDate 'the xml item date (rss format) 'file handlers dim causesXML, picturesXML, writingXML 'xml set holders dim causes, pictures, writing 'lengths of xml files dim causesLength, picturesLength, writingLength 'counters to keep track of where we are in each xml file dim causesCount, picturesCount, writingCount 'variables to track dates for each type dim causesDate dim picturesDate dim writingDate dim biggestDate dim biggestType 'create the filesystem and xml objects set fileSystem = Server.CreateObject("Scripting.FileSystemObject") set causesXML = Server.CreateObject("Microsoft.XMLDOM") set picturesXML = Server.CreateObject("Microsoft.XMLDOM") set writingXML = Server.CreateObject("Microsoft.XMLDOM") 'do not do asynchronous download 'picturesXML.async = False 'map directories set rssDir = fileSystem.GetFolder(Server.MapPath("rss/")) set xmlDir = fileSystem.GetFolder(Server.MapPath("xml/")) 'set filename rssFile = rssDir & "\rss.xml" 'write the image response.write "
" 'load the xml files causesXML.Load(xmlDir & "\causes.xml") picturesXML.Load(xmlDir & "\pictures.xml") writingXML.Load(xmlDir & "\writing.xml") 'get the specific entries set causes = causesXML.getElementsByTagName("cause") set pictures = picturesXML.getElementsByTagName("gallery") set writing = writingXML.getElementsByTagName("entry") 'get the lengths causesLength = causes.length picturesLength = pictures.length writingLength = writing.length 'set up counters for each file causesCount = 0 picturesCount = 0 writingCount = 0 'get the newest date for our lastBuildDate biggestDate = causes.item(0).childNodes(xmlPubDate).text if pictures.item(0).childNodes(xmlPubDate).text > biggestDate then biggestDate = pictures.item(0).childNodes(xmlPubDate).text end if if writing.item(0).childNodes(xmlPubDate).text > biggestDate then biggestDate = writing.item(0).childNodes(xmlPubDate).text end if 'create the rss file set rss = fileSystem.CreateTextFile(rssFile) rss.WriteLine("") rss.WriteLine(" daveberlin.com") rss.WriteLine(" http://www.daveberlin.com") rss.WriteLine(" Dave Berlin's website--the latest pictures, writing, and more from daveberlin.com") rss.WriteLine(" en-us") rss.WriteLine(" " & currentDate & "") rss.WriteLine(" " & biggestDate & "") rss.WriteLine(" dave@daveberlin.com (Dave Berlin)") rss.WriteLine(" webmaster@daveberlin.com") rss.WriteLine(" Copyright (c) 2006 daveberlin.com, all rights reserved") rss.WriteLine(" 60") rss.WriteLine(" ") rss.WriteLine(" http://www.daveberlin.com/images/home_780_480.jpg") rss.WriteLine(" daveberlin.com") rss.WriteLine(" http://www.daveberlin.com") rss.WriteLine(" 88") rss.WriteLine(" 31") rss.WriteLine(" ") 'write the newest items for i = 0 to (numItems - 1) response.write "
" & i & "
" response.write "causesCount: " & causesCount & "
" response.write "picturesCount: " & picturesCount & "
" response.write "writingCount: " & writingCount & "
" 'get the date for each set if causesCount < causesLength then causesDate = causes.item(causesCount).childNodes(xmlDate).text response.write "causesDate: " & causesDate & "
" end if if picturesCount < picturesLength then picturesDate = pictures.item(picturesCount).childNodes(xmlDate).text response.write "picturesDate: " & picturesDate & "
" end if if writingCount < writingLength then writingDate = writing.item(writingCount).childNodes(xmlDate).text response.write "writingDate: " & writingDate & "
" end if 'choose the biggest (newest) date biggestDate = "1970-01-01" biggestType = "none" if causesCount < causesLength and causesDate > biggestDate then response.write "evaluating causesDate
" biggestDate = causesDate biggestType = "causes" end if if picturesCount < picturesLength and picturesDate > biggestDate then response.write "evaluating picturesDate
" biggestDate = picturesDate biggestType = "pictures" end if if writingCount < writingLength and writingDate > biggestDate then response.write "evaluating writingDate
" biggestDate = writingDate biggestType = "writing" end if response.write "biggestType: " & biggestType & "
" response.write "biggestDate: " & biggestDate & "
" 'get the information from that item title = eval(biggestType).item(eval(biggestType & "Count")).childNodes(xmlTitle).text category = eval(biggestType & "XML").getElementsByTagName("category").item(xmlCategory).text link = eval(biggestType).item(eval(biggestType & "Count")).childNodes(xmlPermalink).text description = eval(biggestType).item(eval(biggestType & "Count")).childNodes(xmlDescription).text pubDate = eval(biggestType).item(eval(biggestType & "Count")).childNodes(xmlPubDate).text response.write "title: " & title & "
" response.write "category: " & category & "
" response.write "link: " & link & "
" response.write "description: " & description & "
" response.write "pubDate: " & pubDate & "
" 'write that item to output rss.WriteLine(" ") rss.WriteLine(" " & title & " (" & category & ")") rss.WriteLine(" " & link & "") rss.WriteLine(" " & description & "") rss.WriteLine(" " & pubDate & "") rss.WriteLine(" ") 'increment the counter for the item we chose select case biggestType case "causes" causesCount = causesCount + 1 case "pictures" picturesCount = picturesCount + 1 case "writing" writingCount = writingCount + 1 end select next 'end of rss file rss.WriteLine("
") 'close files rss.Close 'remove handlers set causes = nothing set pictures = nothing set writing = nothing set causesXML = nothing set picturesXML = nothing set writingXML = nothing set rss = nothing set rssDir = nothing set xmlDir = nothing set fileSystem = nothing %>