<% 'str = xpath, key = key name sub getShallowData(str,key) set obj = xml.getElementsByTagName(str) For i = 1 to ((obj.length)) execute("r"&(i)&".Add """&key&""" , """&obj.item(i-1).text&"""") 'Response.write "r"&(i)&".Add """&key&""" , """&obj.item(i-1).text&"""
" next End sub 'str = string to search, searchFor = string to search for Function setCurrencyandPeroid(str,searchFor) StringToSearch = str Set RegularExpressionObject = New RegExp With RegularExpressionObject .Pattern = searchFor .IgnoreCase = True .Global = True End With expressionmatch = RegularExpressionObject.Test(StringToSearch) setCurrencyandPeroid = expressionmatch end Function 'str = xpath sub getPerData(str) Dim keyStr(2) if (setCurrencyandPeroid(str,"dollars") and setCurrencyandPeroid(str,"perweek")) then keyStr(0) = "dollars1004pw" keyStr(1) = "dollars0509pw" elseif (setCurrencyandPeroid(str,"dollars") and setCurrencyandPeroid(str,"pernight")) then keyStr(0) = "dollars1004pn" keyStr(1) = "dollars0509pn" elseif (setCurrencyandPeroid(str,"sterling") and setCurrencyandPeroid(str,"perweek")) then keyStr(0) = "sterling1004pw" keyStr(1) = "sterling0509pw" elseif (setCurrencyandPeroid(str,"sterling") and setCurrencyandPeroid(str,"pernight")) then keyStr(0) = "sterling1004pn" keyStr(1) = "sterling0509pn" end if tripSwitch = 0 dictionaryNumber = 1 set obj = xml.getElementsByTagName(str) For i = 1 to ((obj.length)) tripSwitch = tripSwitch+1 execute("r"&(dictionaryNumber)&".Add """&keyStr(tripSwitch-1)&""" , """&obj.item(i-1).text&"""") ' Response.write "r"&(dictionaryNumber)&".Add """&keyStr(tripSwitch-1)&""" , """&obj.item(i-1).text&"""
" if tripSwitch = 2 then tripSwitch = 0 dictionaryNumber = dictionaryNumber + 1 end if next End sub Function setGlobalVars(str) set obj = xml.getElementsByTagName(str) setGlobalVars = obj.item(0).text end function '****************** Main Body ****************** 'declare an array of all the xpaths for all details needed for each room Dim roomInfo(6) roomInfo(0) = "tariff/item/roomtype" roomInfo(1) = "tariff/item/peroid/pernight/sterling" roomInfo(2) = "tariff/item/peroid/pernight/dollars" roomInfo(3) = "tariff/item/peroid/perweek/sterling" roomInfo(4) = "tariff/item/peroid/perweek/dollars" 'load the document Dim xml Set xml = Server.CreateObject("Microsoft.XMLDOM") xml.async = False 'load the xml 'xml.load (Server.MapPath("admin/Data/"&Request.QueryString("property"))) xml.load (Server.MapPath("admin/Data/"&sXML)) 'make sure that there arn't any errors If XML.parseError.errorCode <> 0 Then 'response.write XML.parseError.errorCode response.write XML.parseError.reason &"
" response.write XML.parseError.filepos&"
" End If 'find out the number of rooms as each room will have a dictionary object of its own noOfRoomTypes = xml.getElementsByTagName("tariff/item/roomtype").length 'create dictionary objects for each room (r1,r2,r3...etc) For i = 1 to noOfRoomTypes 'Response.write "dictionary object r"&i &" created...
" execute("Set r"&i&" = CreateObject(""Scripting.Dictionary"")") next 'Response.write "

" 'populate shallow data into respective dictionaries getShallowData roomInfo(0),"roomtype" 'set tariff info getPerData roomInfo(1) getPerData roomInfo(2) getPerData roomInfo(3) getPerData roomInfo(4) 'set global xml data name = setGlobalVars("name") location = setGlobalVars("location") introtext = setGlobalVars("introtext") introimage = setGlobalVars("introimage") locationmap = setGlobalVars("locationmap") 'Response.write "

" %>