Monday, July 5, 2010

Working with XML

Hi, following post will give you a clear idea how to update xml element data, with the help of installshield data. This scenario will come where we need to either modify config files at the end of our installation program.


// Set XML Doc Type
set oDoc = CreateObject("Msxml2.DOMDocument.4.0");
oDoc.setProperty("SelectionLanguage", "XPath");


// set up variable with fullpath to config file
szConfigFile = "C:\app.config" ;


// set up the XPath for your target node and setting you are going to change
szXPath = "/configuration/userSettings/Client.Properties.Settings/setting[@name='WebUrl']";


// load the XML document into memory
if oDoc.load(szConfigFile) then


//Set the XPath in the XML
set oNode = oDoc.documentElement.selectSingleNode(szXPath);


//Update the XML Element
oNode.text = szCurrentURI;


endif;


// Save the XML Changes
oDoc.save(szConfigFile);


set oDoc = NOTHING;

No comments:

Post a Comment