Java Reference
In-Depth Information
versions installed before you can use them, and the version selection code can become complex.
Thankfully, Microsoft recommends checking for only two versions of MSXML. Their version strings
are as follows:
Msxml2.DOMDocument.6.0
Msxml2.DOMDocument.3.0
You want to use the latest version possible when creating an XML DOM, and the following function
does this:
function createDocument()
{
var xmlDoc;
if (window.ActiveXObject)
{
var versions =
[
“Msxml2.DOMDocument.6.0”,
“Msxml2.DOMDocument.3.0”
];
for (var i = 0; i < versions.length; i++)
{
try
{
xmlDoc = new ActiveXObject(versions[i]);
return xmlDoc;
}
catch (error)
{
//do nothing here
}
}
}
return null;
}
This code defi nes the createDocument() function. Its fi rst line creates the xmlDoc variable. This is a
temporary variable used in the creation of an XML DOM. The next line of code is an if statement, and
it checks to see if the browser is IE by seeing if window.ActiveXObject exists. If the condition is true ,
then an array called versions is created, and the two MSXML versions are added as elements to the
array.
var versions =
[
“Msxml2.DOMDocument.6.0”,
“Msxml2.DOMDocument.3.0”
];
Search WWH ::




Custom Search