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
- :
- Re: XML File changes -Append-
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
‎Nov 15, 2010
12:31 AM
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
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
(2) Replies
‎Nov 15, 2010
10:16 AM
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.
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.
‎Oct 14, 2011
02:58 PM
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