Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: M1TO on February 13, 2025, 01:07:46 am

Title: Reading xml file from Script x86 vs. x64 version
Post by: M1TO on February 13, 2025, 01:07:46 am
I have a JScript reading an xml file. Everything is working fine in EA 15.2. Now I tested the script in EA 16.1 (x64) and neither xmlDom.selectSingleNode("/name") nor rootNode.getElementsByTagName("name") works.
Does anybody know why? The xml is loaded correctly and I can still get the rootNode with rootNode = xmlDom.documentElement.
Title: Re: Reading xml file from Script x86 vs. x64 version
Post by: Geert Bellekens on February 13, 2025, 01:25:42 am
Can you share a representive sample that demonstrates the problem, including the exact errors you are gettign.

"it isn't working" is generally not very helpful.

Geert
Title: Re: Reading xml file from Script x86 vs. x64 version
Post by: M1TO on February 13, 2025, 05:38:07 pm
Sure  :)

So in EA 15 I am using the functions provided in JScript-XML in the EAScriptLib. It basically does that:
Code: [Select]
xmlDOM = new ActiveXObject("MSXML2.DOMDocument.6.0");
xmlDOM.loadXML("path\\to\\theXMLfile");

then I get the root node and later read single nodes:
Code: [Select]
rootNode = xmlDOM.documentElement;
...
xmlNode = rootNode.getElementsByTagName("nodeName");
if (xmlNode.length != 0)
{
    /* read data from node */
}

As I said, that works in EA 15. The same does not in EA 16 x64. There, the xmlNode.length is always 0. But loadXML did not return an error and the root node looks also the same.
Title: Re: Reading xml file from Script x86 vs. x64 version
Post by: Geert Bellekens on February 13, 2025, 06:23:33 pm
Ah, that could be the issue.

The code in the JScrip-XML doesn't simply create a DomDocument of a specific version. It tries different version and returns the first one that works.

Code: [Select]
switch (attempt++)
{
case 0: ProgId = "MSXML2.DOMDocument.6.0"; break; //MSXML 6.0
case 1: ProgId = "MSXML2.DOMDocument.3.0"; break; //MSXML 3.0
case 2: ProgId = "MSXML2.DOMDocument"; break; //MSXML 3.0
case 3: ProgId = "MSXML2.DOMDocument.4.0"; break; //MSXML 4.0
default: LOGWarning("Could not create DOMDocument."); return;
}

I'm guessing there will be a difference between the DOMDocument created in 32 bit vs the one created in 64 bit.
You can step through the code using the debugger to make sure.

Quite possibly the required libraries are not installed on your machine for 64 bit, and you are working with another version of the DOMDocument library that doesn't support the methods you are using.

Geert
Title: Re: Reading xml file from Script x86 vs. x64 version
Post by: M1TO on February 13, 2025, 07:15:56 pm
Yes, I saw that too. In both cases, it creates an MSXML 6.0 object. And the dll is installed for 32 bit and 64 bit.
When I force the created object to be "MSXML2.DOMDocument" the entire script works for 64 bit though.  :o
Title: Re: Reading xml file from Script x86 vs. x64 version
Post by: Geert Bellekens on February 13, 2025, 08:33:46 pm
Yes, I saw that too. In both cases, it creates an MSXML 6.0 object. And the dll is installed for 32 bit and 64 bit.
When I force the created object to be "MSXML2.DOMDocument" the entire script works for 64 bit though.  :o

That is not what I would expect, but hey, if it works, it works  ;D

Geert
Title: Re: Reading xml file from Script x86 vs. x64 version
Post by: M1TO on February 13, 2025, 08:36:49 pm
That is not what I would expect, but hey, if it works, it works  ;D

There's some truth to that. But it is still kind of unsatisfying that I have to distinguish between the two versions.