cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
raffaeu
Level 3

InstallScript read XML not working as expected

I have a simple XML file that needs to be read from my InstallScript module.
The structure of the XML is the following:




xmlns="http://company.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://company.com SuiteConfiguration_schema.xsd">




user
password



And this is the code I am using to read the XML:

	/*------------------------------------------------------------------
Load the XML parser
--------------------------------------------------------------------*/
try
set xml = CoCreateObject("Microsoft.XMLDOM");
xml.async = FALSE;
xml.setProperty("SelectionLanguage", "XPath");
xml.setProperty("SelectionNamespaces", "xmlns='http://company.com'");
MessageBox("XML created", INFORMATION);
/*------------------------------------------------------------------
Load the XML document
--------------------------------------------------------------------*/
if(xml.Load(OLD_FILE)) then
MessageBox("Document loaded", INFORMATION);
/*--------------------------------------------------------------
Parse the database section
----------------------------------------------------------------*/
set node = xml.selectSingleNode(xml, "//Configuration/Database/Credentials/@Authentication");
MessageBox(node, INFORMATION);
else
MessageBox("Document can't be loaded", SEVERE);
endif;
catch
MessageBox("CoCreateObject Failed- "+ Err.Decription, SEVERE);
endcatch;


The issue is that the script executes, I get two messageboxes ("XML created" and "Loaded") but the node selected using XPath does not even execute that piece of code because the third messagebox is not even displayed
and no errors are thrown ...

Actually I am getting lost, any idea?
Labels (1)
0 Kudos
(1) Reply
raffaeu
Level 3

I found the error by myself, it was related to the fact the I was not mentioning the namespace within the XMLDOM object.
In my case I am using some namespaces so I had to declare a "fake" prefix in order to be able to execute the XPath query properly.

set xml = CoCreateObject("Microsoft.XMLDOM");
xml.async = FALSE;

// set the XPath and Namespaces properties
xml.setProperty("SelectionLanguage", "XPath");
xml.setProperty("SelectionNamespaces", "xmlns:ns='http://mproof.com'");

// create an XPath query
output = xml.selectNodes("//ns:Database/ns:Credentials")(0).text;
0 Kudos