Community Forums
Results 1 to 2 of 2

Thread: Need to pass values from XML file to msi at run time

  1. #1
    Join Date
    Dec 2018
    Posts
    1

    Need to pass values from XML file to msi at run time

    I have been given an xml file and the values from this file needs to be passed to an msi on run time. Can someone help me with this?

  2. #2
    Join Date
    Jul 2003
    Location
    North Kingstown, RI, USA
    Posts
    1,356
    I have done this in my Suite package using InstallScript. The code below can be modified to work with MSI. In this code I implement a generalized logging method that simply calls SuiteLogInfo, but you can call SprintfMsiLog instead.
    This code snippet is part of a method where I pass in the element name and get its value. I do not have code to get XML attributes.

    Code:
    	szFile = szSourceFilePath ^ "mysourceFile.xml";
    	SuiteLogInfo("Searching for xml value in %s", szFile);
    	if (Is(FILE_EXISTS, szFile)) then
    		//Open file for read permission
    		try
    			OpenFileMode(FILE_MODE_NORMAL);
    			if (OpenFile(nvFileHandle, szInstallPath, "systemsettings.xml") < 0) then
    				Err.Raise(ERROR_OPEN_FAILED);
    			endif;
    			
    			while (GetLine(nvFileHandle, svLine) == 0)
    				//GetValueIfFound
    				SuiteLogInfo("Searching for %s in line: %s", p_szName, svLine);
    				if (StrFindEx(svLine, p_szName, 0) >= 0) then	
    				    //Trim leading spaces
    				    StrTrim(svLine);
    				    SuiteLogInfo("INFORMATION: Found value for %s in systemsettings.xml", p_szName);
    					posStart = StrFindEx(svLine,">",0) + 1;
    					posEnd = StrFindEx(svLine, "</", posStart);
    					SuiteLogInfo("INFORMATION: grabbing value between position %d and %d",posStart, posEnd);
    					StrSub(svValue, svLine, posStart, posEnd-posStart);
    					return svValue;					
    				endif;
    			endwhile; 
    		catch
    			/* Exception handler */
    			SuiteLogInfo("WARNING: Unable to obtain information for %s from systemsettings.xml", p_szName);
    		endcatch;
    Regards,
    Dan Lee

    Release Engineer

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •