[thelist] Detecting versions of XML parser in IE?

Hardacker, Andrew Andrew.Hardacker at Compuware.com
Tue Mar 12 17:11:00 CST 2002


<snip>
Is there a way (through javascript, presumably) to detect the version of
XML parser in IE? We're doing some stuff that apparently IE 5.0 (and its
ome parser) doesn't like.
</snip>

Scott,

I don't believe MSXML exposes version information to the browser. I also
needed to know and now do two checks against the MSXML parser. The first is
a JavaScript function that simply tests the ActiveXObject:

var oXML = null;
var versionMSXML = null;
function initMSXML() {
 try {
  oXML = new ActiveXObject("MSXML2.DOMDocument.4.0");
  versionMSXML = 4;
 } catch(msxmlError) {
  oXML = new ActiveXObject("MSXML.DOMDocument");
  versionMSXML = 3;
 }
}

I also check to make sure that at least version 3 patch level 1 is installed
by running a tiny XSL transformation on page load. The transform process
includes the stylesheet compilation step which is itself part of the
verification process. If the result = "OK", we're, well, OK. If MSXML4 is
not installed, I attempt to install it automatically, using the cab files
snagged from the Microsoft site. (MSXML4 is vastly superior to 3. IE5 ships,
or did at one time, with the unpatched version 3.)

The test XML:
<?xml version="1.0" encoding="UTF-8"?>
<test ok="OK"/>

The test XSL:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" encoding="UTF-8"/>
<!-- stylesheet: Browser test -->
<!-- copyright 2001 Compuware Corporation, APMpower Lab, Cambridge, MA -->
<xsl:decimal-format name="no-NaN" NaN=""/> <!-- checks for MSXML 3 patch 1
(unpatched 3 blows up here) -->
<xsl:template match="/">
  <xsl:value-of select="/test/@ok"/>
</xsl:template>
</xsl:stylesheet>

Andy
andy at hardacker.com



More information about the thelist mailing list