I'm having a strange trouble with MSXML2.DOMDocument ActiveX Object. Here is my code:
var doc = new ActiveXObject('MSXML2.DOMDocument.6.0');
doc.LoadXML('<test1><test2>Hello!</test2></test1>');
The typeof the doc variable is object and there was no exceptions at the first line of the code. However the second line throws that the object doesn't support the method. I can't really understand why, but it seems that is fails on any method (I tried LoadXML, Load, Async and etc) with the same message.
Your biggest problem is that the method name is loadXML()
, not LoadXML()
. The method name is case-sensitive.
If you ever get stuck trying to figure out the methods supported by a particular COM object, you can use PowerShell to list the available methods like this:
powershell "new-object -COM MSXML2.DOMDocument.6.0 | gm"
Also, if you find that you're having trouble navigating the DOM with that string, you might need to include <?xml version="1.0"?>
before the <test>
tag. Some of MS's XML parsers are pedantic about valid, well-formed XML structure. I'm not sure how strict or tolerant MSXML2.DOMDocument.6.0
is about such things.