Testing for the XMLHTTP Request object

Submitted by:Pitter Alderson

Date added:29 March, 2012


Run the script to test whether you have the XMLHTTP Request object installed that comes with any version of the Microsoft XML Parser (MSXML).

Tags: xml parser

Code Snippet:

<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>XMLHTTP Request Object</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
'put the objects that we wish to test for into a declared array
Dim InstalledObjects(4)

InstalledObjects(0) ="Microsoft.XMLHTTP"
InstalledObjects(1) ="Msxml2.ServerXMLHTTP"
InstalledObjects(2) ="MSXML2.ServerXMLHTTP"
InstalledObjects(3) ="MSXML2.XMLHTTP.3.0"
InstalledObjects(4) ="MSXML2.XMLHTTP.4.0"

Function ObjCreated(sClass)
'create variable
Dim ObjInstance
On Error Resume Next
'initialize default values
ObjCreated = False
'create instance of the class - an object
Set ObjInstance = Server.CreateObject(sClass)
If Err.Number=0 Then ObjCreated = True
'close object
Set ObjInstance = Nothing
End Function
<table border="0">
Dim i
For i=0 to UBound(InstalledObjects)
Response.Write "<tr><td>" & InstalledObjects(i) & "</td><td>"
If ObjCreated(InstalledObjects(i)) Then
Response.Write "<strong>Installed</strong>"
Response.Write "<strong>not installed</strong>"
End If
Response.Write "</td></tr>"