This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- InstallScript read XML not working as expected
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
Mar 12, 2014
07:14 AM
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:
And this is the code I am using to read the XML:
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?
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?
(1) Reply
Mar 12, 2014
08:14 AM
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.
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;