Home All Groups Group Topic Archive Search About
Author
6 Nov 2006 1:48 PM
Norman Chong
Hi,

I want to get my MSXML version from a vb.net program. I do it with the
following piece of code, but I'm not very happy with that:

Dim Version as String = "4.0"
oXML = CreateObject("Msxml2.DOMDocument.4.0") 'Need version 4.
   If oXML Is Nothing Then 'Check the existing version
      oXML = CreateObject("MSXML2.DOMDocument.3.0")
      Version = "3.0"
      If oXML Is Nothing Then
         oXML = CreateObject("MSXML2.DOMDocument.2.6")
         Version = "2.6"
         If oXML Is Nothing Then
            oXML = CreateObject("MSXML2.DOMDocument")
            Version = "2.0"
            If oXML Is Nothing Then
               Version = "Not detected"
            End If
         End If
      End If
   End If

Does anybody know a more elegant way to do this?

Thanks,
Norman

Author
6 Nov 2006 2:18 PM
Martin Honnen
Norman Chong wrote:

> I want to get my MSXML version from a vb.net program.

The .NET framework has its own classes/implementations for XML parsing,
XSLT, XPath, DOM, schema validation, you should not use MSXML from .NET.

Show quoteHide quote
> I do it with the
> following piece of code, but I'm not very happy with that:
>
> Dim Version as String = "4.0"
> oXML = CreateObject("Msxml2.DOMDocument.4.0") 'Need version 4.
>    If oXML Is Nothing Then 'Check the existing version
>       oXML = CreateObject("MSXML2.DOMDocument.3.0")
>       Version = "3.0"
>       If oXML Is Nothing Then
>          oXML = CreateObject("MSXML2.DOMDocument.2.6")
>          Version = "2.6"
>          If oXML Is Nothing Then
>             oXML = CreateObject("MSXML2.DOMDocument")
>             Version = "2.0"
>             If oXML Is Nothing Then
>                Version = "Not detected"
>             End If
>          End If
>       End If
>    End If
>
> Does anybody know a more elegant way to do this?

It is not clear what you want to achieve, the latest version of MSXML is
MSXML 6 for instance. And MSXML 3, 4, 5, 6 can all coexist on the same
system. The programming id MSXML2.DOMDocument can be bound to MSXML 3
depending on the installation, with the normal IE 6 installation it is
bound to MSXML 3.

--

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/
Author
6 Nov 2006 2:47 PM
Norman Chong
Martin Honnen schrieb:

>
> It is not clear what you want to achieve, the latest version of MSXML is
> MSXML 6 for instance. And MSXML 3, 4, 5, 6 can all coexist on the same
> system. The programming id MSXML2.DOMDocument can be bound to MSXML 3
> depending on the installation, with the normal IE 6 installation it is
> bound to MSXML 3.
>

Sorry if it was unclear what I want to do - I try it again ;-)
The program should check, if there is MSXML 4.0 installed (it has to do
this for another application, which needs 4.0 - That's why I started
with 4.0 in my code), if not it should get the next lower version which
is installed and show it within a MessageBox.