Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to check DOMDocument version at run time?

5 views
Skip to first unread message

Leo

unread,
Aug 31, 2010, 11:33:26 PM8/31/10
to
How can I check / find out the DOMDocument version, i.e.,
DOMDocument30, DOMDocument60, ? Thanks.

Martin Honnen

unread,
Sep 1, 2010, 7:53:15 AM9/1/10
to
Leo wrote:
> How can I check / find out the DOMDocument version, i.e.,
> DOMDocument30, DOMDocument60, ? Thanks.

I don't know of a direct way to find that out, however when you run XSLT
you can access
system-property('msxsl:version')
to find out the MSXML version (e.g. 3 or 6). Here is an example with
JScript that implements a function getVersion which takes an MSXML DOM
document, clones it, loads a stylesheet to output the version and runs
that stylesheet to return the version:

function getVersion(doc) {
var sheet = doc.cloneNode(false);
sheet.loadXML([
'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">',
' <xsl:output method="text"/>',
' <xsl:template match="/">',
' <xsl:value-of select="system-property(\'msxsl:version\')"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"/>',
' </xsl:template>',
'</xsl:stylesheet>'
].join('\r\n'));
return doc.transformNode(sheet);
}

var doc = new ActiveXObject('Msxml2.DOMDocument.3.0');

// use with e.g.
alert(getVersion(doc))


--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/

0 new messages