cancel
Showing results for 
Search instead for 
Did you mean: 
Bineesh
Pilgrim

XML File changes -Append-

Hi,
I am doing some XML file update while installation (appending some values to the existing values in the XML). While uninstall and reinstall it is appending again the same values. How to handle this? If I give remove the element on uninstall will remove the complete xml tag or only the appended part?

I am using Basic MSI project.

Regards,
Bineesh
Labels (1)
0 Kudos
2 Replies
chrislynn5
Pilgrim

Re: XML File changes -Append-

Maybe this is helpful. I tried using the XML File changes option in System Configuration but found that since I was using dynamic, user dialog set values, that those were not being used at XML alter time. If you are not doing that then try that option, or:
So I approached this via custom action, which has script running options.
I'm running this action after my global values are set via the user dialog I created. NOTE: Then set custom script to run only on install.
Using VBScript in the custom action option, I wrote this (launched after Install finalize): (you can see I'm updating an XML files customers number via the value entered on my users dialog)

Dim xmlFile
xmlFile = Session.Property("INSTALLDIR") + "\xxxxxxx\" + Session.Property("CUSTOMERNBR") + "\xxxxxx\xxxxxxx.xml"
DIM fso
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(xmlFile)) Then
set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.Async = False
xmlDoc.Load(xmlFile)
Set node = xmlDoc.documentElement.SelectSingleNode("application_meta/NODENAME")
node.Text = Session.Property("xxxxxxxxx")
Set node = xmlDoc.documentElement.SelectSingleNode("./@targetnodename")
node.Text = Session.Property("xxxxxxxxxx")
xmlDoc.Save(xmlFile)
End If

For different situations, remove, uninstall, etc, run different scripts.
0 Kudos
operaza
Pilgrim

Re: XML File changes -Append-

Bineesh wrote:
Hi,
I am doing some XML file update while installation (appending some values to the existing values in the XML). While uninstall and reinstall it is appending again the same values. How to handle this? If I give remove the element on uninstall will remove the complete xml tag or only the appended part?

I am using Basic MSI project.

Regards,
Bineesh


I found that same problem a while back, I solved it by modifying the default xpath expression that installshield creates when you import the file by first time.

I was updating attribute in an xml file with this structure:






In my case this was the installshield xpath created when importing the file:
for the first add element:
add[@key="blablabla" and @value="blablabla2"]

With the xpath above duplicated entries were created when repairing etc...

modifying the above xpath expression to:
add[@key="blablabla"]

fixed it in my case
0 Kudos