Entry
Which program id (e.g. Microsoft.XMLHTTP, Msxml2.XMLHTTP) do I need to use with which version of IE?
Which program id (e.g. Microsoft.XMLDOM, Msxml2.DOMDocument) do I need to use with which version of IE?
Apr 22nd, 2005 03:46
Martin Honnen, http://support.microsoft.com/?kbid=269238
IE (talking about IE/Win only here) does not have a built-in XML parser
but makes use of what is known as MSXML, sometimes called _M_icro_S_oft
XML parser, sometimes called _M_icro_S_oft XML core services. MSXML
exists in different versions and while each IE version since IE 5
installs a needed MSXML version it is possible to update or install new
versions of MSXML on a system without updating IE.
If you want to use MSXML with script you are left with task of using the
right program id e.g. in JScript for
new ActiveXObject('program.id')
you need to know which program id to use.
For MSXML there are version dependent and version independent program
ids. In general if you are scripting on the client and assuming you do
not know which version of IE and which version of MSXML your visitors
have installed then you are better off using version independent program
ids as that way if an MSXML version is around that is bound to that
program id you can instantiate it without needing to know about the
exact MSXML version.
The version independent program id for an XML DOM document is
Microsoft.XMLDOM
thus
var xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
creates an XML DOM document in IE 5 or later.
The version independent program id for an XML HTTP request object is
Microsoft.XMLHTTP
thus
var httpRequest = new ActiveXObject('Microsoft.XMLHTTP');
creates an XML HTTP request object in IE 5 or later.
Which actual MSXML version such a program id is bound to depends on the
MSXML version(s) installed and even on the mode (side-by-side or replace
mode) a version is installed in.
Version dependent program ids make sense if you are scripting on a
server where you know which version of MSXML is installed or if you are
scripting in an intranet where you also know which version of MSXML is
installed on all clients or if you want to use a specific feature that
you know is only supported by a certain version of MSXML.
The version dependent program ids for an XML DOM document for MSXML 3,
4, and 5 look as follows:
Msxml2.DOMDocument.version.number
e.g. to create an XML DOM document as implemented by MSXML 3 you need
var xmlDocument = new ActiveXObject('Msxml2.DOMDocument.3.0');
the MSXML 4 version is created as
var xmlDocument = new ActiveXObject('Msxml2.DOMDocument.4.0');
and the MSXML 5 version as
var xmlDocument = new ActiveXObject('Msxml2.DOMDocument.5.0');
The respective version dependent program ids for an XML HTTP request
object for MSXML 3, 4, and 5 look as follows:
Msxml2.XMLHTTP.version.number
e.g. to create an XML HTTP request object as implemented by MSXML 3 you need
var httpRequest = new ActiveXObject('Msxml2.XMLHTTP.3.0');
the MSXML 4 version is created as
var httpRequest = new ActiveXObject('Msxml2.XMLHTTP.4.0');
the MSXML 5 version as
var httpRequest = new ActiveXObject('Msxml2.XMLHTTP.5.0');
Note that from MSXML 4 on there are only version dependent program ids
so that the earlier version independent program ids are never bound to
MSXML 4 or 5.
Here are more infos on program ids for MSXML 3:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmmscMSXML3_GuidsandProgIDs.asp
MSXML 4:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmmscMSXML4_GuidsandProgIDs.asp
MSXML 5:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmmscMSXML5_GuidsandProgIDs.asp