class clsDocumentLoader private a__,b__,c__,d__ public property get LastReturnCode LastReturnCode=b__ end property private property let LastReturnCode(Value) b__=Value end property public property get LastLoadedPath LastLoadedPath=a__ end property private property let LastLoadedPath(Value) a__=Value end property public property get LastLoadSuccessful LastLoadSuccessful=not IsEmptyStr(f__) or ((LastReturnCode=200) and RunningFromWebServer) end property private property get e__ set e__=c__ end property private property get f__ f__=d__ end property private property let f__(Value) d__=Value end property private sub class_initialize set c__=CreateObject("Microsoft.XMLHttp") d__="" b__=0 a__="" end sub private sub class_terminate set c__=nothing end sub public function LoadXML(AFilePath) Reset f__="" a__=AFilePath dim g__ set g__=StandardLoad(AFilePath) if IsValidObject(g__) then f__ = g__.XML if IsEmptyStr(f__) and RunningFromWebServer then if DoRequest(AFilePath) then f__ = e__.ResponseXML.XML if IsEmptyStr(f__) then dim h__ h__=RelativeToAbsolutePath(GetFullFolderPath, APath) if DoRequest(h__) then f__ = e__.ResponseXML.XML end if end if g__.LoadXML(f__) if g__.ParseError.ErrorCode <> 0 then set g__ = nothing end if set LoadXML=g__ end function private function StandardLoad(APath) dim g__ set g__=CreateDOMObject g__.Load(APath) if IsEmptyStr(g__.XML) then if IsRelativePath(APath) then dim h__ h__=RelativeToAbsolutePath(GetFullFolderPath, APath) g__.Load(h__) end if end if set StandardLoad=g__ end function public function LoadFromString(AString) dim g__ set g__=CreateDOMObject g__.LoadXML(AString) set LoadFromString=g__ end function public function LoadXSL(AFilePath) Reset a__=AFilePath dim g__ set g__=CreateDOMObject g__.Load(Escape(LastLoadedPath)) set LoadXSL=g__ end function private function DoRequest(APath) DoRequest=false Err.Clear on error resume next if IsRelativePath(APath) then e__.Open "GET", RelativeToAbsolutePath(GetFullFolderPath, APath), false :else: e__.Open "GET", APath, false e__.SetRequestHeader "Accept-Encoding", "gzip, deflate" if IsEmptyStr(Err.Description) then e__.Send LastReturnCode=e__.Status if LastReturnCode = 200 then DoRequest = true end if end function private sub Reset LastReturnCode=200 end sub public sub ShowLastError select case LastReturnCode case 200 msgbox "Request was completed successfully." case 401 msgbox "Error retrieving '" & LastLoadedPath & "', you are not authorized to access this file (HTTP 401 Error)!" case 403 msgbox "Error retrieving '" & LastLoadedPath & "', you are not authorized to access this file (HTTP 403 Error)!" case 404 msgbox "Error retrieving '" & LastLoadedPath & "', file not found (HTTP 404 Error)!" case 408 msgbox "Error retrieving '" & LastLoadedPath & "', request timed-out (HTTP 408 Error)! Please try again." case else if (LastReturnCode >= 400) and (LastReturnCode < 500) then msgbox "Error retrieving '" & LastLoadedPath & "'. Client error, server returned code: " & LastReturnCode if (LastReturnCode >= 500) and (LastReturnCode < 600) then msgbox "Error retrieving '" & LastLoadedPath & "'. Server error, server returned code: " & LastReturnCode end select end sub end class