cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vs20082010
Level 4

Help please... XML load error :(

I'm trying to update an xml file this code works except for the xml file location. I want to update the xml file after it has been installed to the [INSTALLDIR]:


strFileName = INSTALLDIR ^ "\\mobile.xml\\";


I got an error after the loading of the xml... what code should I use to find the location of the not yet installed xml file in that [INSTALLDIR] because the installer has not yet finished installing it?


And If I would place this in the custom action, where should i put this?


thank you very much!



------

function ModifyWebConfig(hMSI)

OBJECT oDoc, oNode, oNodeList;
NUMBER i,nSize,nResult, nTemp ;
STRING strNamedItem;
STRING strFileName ;
STRING svFileURLName ;
BOOL bTryAgain;

begin

bTryAgain =FALSE;
strFileName = INSTALLDIR ^ "\\mobile.xml\\";

// Get the path of the license directory path name.

AskText (MSG_TEXT, DEFAULT_PATH, svFileURLName );

//====================================================

///////////////////////////////////////////////////////////////////////////
// get values from public properties
///////////////////////////////////////////////////////////////////////////
set oDoc = CreateObject("Msxml2.DOMDocument.3.0");

if (IsObject(oDoc) = FALSE) then
MessageBox(ERROR_XML_FILE_CREATION, 0);
return -1;
endif;

oDoc.async = FALSE;
oDoc.setProperty("SelectionLanguage", "XPath");

///////////////////////////////////////////////////////////////////////////
// if success, traverse file and substitute value //
///////////////////////////////////////////////////////////////////////////
if oDoc.load(strFileName) then
///////////////////////////////////////////////////////////////////////
// get list of matching nodes //
///////////////////////////////////////////////////////////////////////
set oNodeList = oDoc.getElementsByTagName("*");

if (oNodeList.length > 0) then

for i = 0 to (oNodeList.length - 1);

set oNode = oNodeList.nextNode;

try
strNamedItem = oNode.attributes.getNamedItem("key").value;
catch
strNamedItem = "";
endcatch;

try
if strNamedItem = "serviceUrl" then
oNode.attributes.getNamedItem("value").value = svFileURLName ;
endif;
catch
endcatch;

endfor;

else

MessageBox(ERROR_XML_FILE_STRUCTURE,SEVERE);
return -1;

endif;

else

MessageBox(ERROR_XML_FILE_LOAD,SEVERE);
return -1;

endif;

oDoc.save(strFileName);
set oDoc = NOTHING;


end;
Labels (1)
0 Kudos
(4) Replies
ChandanOmkar
Level 8

Call the function ModifyWebConfig() just before the appearance of finish dialog SdFinishEx. It wont give the error.

and also provide the file path as follows :

strFileName = INSTALLDIR ^ "mobile.xml";
0 Kudos
vs20082010
Level 4

ChandanOmkar:

thank you for giving me an idea about this but unfortunately I am doing this in Basic MSI Installer I could not find the SdFinishEx or even SdFinish here.

Where can I place this in the custom action and sequence tab?
0 Kudos
Lurean
Level 8

if you are using a basic MSI file you could look at the XML File Changes view and use that to apply the changes you need to the XML File. Check the IS help section on XML file changes.
0 Kudos
vs20082010
Level 4

Lurean:

thank you for your reply. I have tried this one but for now i was not able to put this in practice: I would like to ask the user to update the url in the xml, this then, i will be placing a string variable perhaps and set its property
(msisetproperty) but it does not get updated in the attribute section. i may be missing something that is why i just used the code instead.



I have made this possible in the installscript code.. but what i wanted to do was just to find the location where i would place this the installer before the setupcompleteprocess is called.
0 Kudos