Prob with XMLDOM

  • Hi all:

    I have this piece of code:
    Set xmldoc = CreateObject("Microsoft.XMLDOM")
    xmldoc.loadXML xs '-> it's a well formed xml string

    Set doc = xmldoc.documentElement
    For Each node In doc.childNodes

    It works OK in XL'97 BUT NOT in XL2000 or XP!!!! It gives a empty doc.

    In order to work i have to change the line

    xmldoc.loadXML xs


    Open "c:\xmldoc.xml" For Output As #1
    Print #1, xs;
    Close #1
    xmldoc.Load "c:\xmldoc.xml"

    What's happening and why? How to correct it properly?

    Many Thanks.

  • Hi xptm and welcome,

    The code below worked for me using XL2000 and a reference to the MSXML version 3 dll.

    NB:Remember to replace the { with <. I couldn't get the message formatted correctly even with BBCode disabled.

    How are you declaring your objects?
    Does xs really contain what you think it does?



  • Hi Andy and thanks for you reply.

    I've tested on XL2000 with MSXML v4 and v2. But i think with XL2000+MSXMLv3 it's the same. It works on XL97+MSXMLv3 and V2. It worked well on a XLXP+MSXMLv3 i think. All the time with the same XML string. And the XML is well formed, it it's not it woeldn´t work either the other way

    Open "c:xmldoc.xml" For Output As #1
    Print #1, xs;
    Close #1
    xmldoc.Load "c:xmldoc.xml"  -&gt; works!

    instead of

    xmldoc.LoadXML xs -&gt; works not!

    The XML string is received from a servlet and it's constructed from a Java ResultSet with a class i've written (open source in if you want to see it). It's a 23587 char string.

    Im using late binding here, cause if i declared it

    Dim xdoc As DOMDocument

    it gives a Type Mysmatch error on XL2000 version on CreateObject(...)

    It does not give the error if i create the doc without the CreateObject, as in

    Dim xdoc as new DomDocument

    but the other error persist. If i declare

    Dim xdoc as new DomDocument40

    everithing works OK, but not in XL97...

    How abot that? :mad::mad:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!