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
- :
- Code for add/update node in xml
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)
Not applicable
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 25, 2011
07:01 AM
duplicate xml node after upgrading
Hi.
We have a product where a xml contains, among other things licensekeys for different modules.
The node only have one property, Licensekey with the value [LICENSEKEY]
The xpath (Element name) is "add[licensekey=[LICENSEKEY]]"
When running a update the element is not found and a duplicate node is created, despite the same node is already present.
It is only a problem in the xml elements where the the element name contains a property.
From the msi log.
Processing XPath '//'
InstallShield 13:55:59: Processing XPath '//CompanyLicense'
InstallShield 13:55:59: Processing XPath '//CompanyLicense/licenses'
InstallShield 13:55:59: Processing XPath '//CompanyLicense/licenses/add[licensekey=[LICENSEKEY]]'
InstallShield 13:55:59: XPath '//CompanyLicense/licenses/add[licensekey=[LICENSEKEY]]' not found, creating
InstallShield 13:55:59: Checking XPath 'CompanyLicense/licenses'
InstallShield 13:55:59: Creating element: Name=add, Namespace=
InstallShield 13:55:59: Node name: 'add' --> Attribute name = 'licensekey', Current Value = '', Operation = '1'
InstallShield 13:55:59: Node name: 'add' - Attribute name = 'licensekey', Old Value = '', New value = 'company=;address1=;address2=;address3=;contact=;exp_date=2011-12-24;issue_date=2011-10-25;modules=BaseServer;type=Trial;signature=Gysr+8XJD7D4TYVObfgONYhedTyCZDM9U8vVGc31bguTk2TWF7AI/g==;', Actual New Value = 'company=;address1=;address2=;address3=;contact=;exp_date=2011-12-01;issue_date=2011-10-25;modules=BaseServer;type=Trial;signature=Gysr+8XJD7D4TYVObfgONYhedTyCZDM9U8vVGc31bguTk2TWF7AI/g==;'
The result is like this
What am I doing wrong? or is this a bug in InstallShield?
Best regards,
Jens
We have a product where a xml contains, among other things licensekeys for different modules.
The node only have one property, Licensekey with the value [LICENSEKEY]
The xpath (Element name) is "add[licensekey=[LICENSEKEY]]"
When running a update the element is not found and a duplicate node is created, despite the same node is already present.
It is only a problem in the xml elements where the the element name contains a property.
From the msi log.
Processing XPath '//'
InstallShield 13:55:59: Processing XPath '//CompanyLicense'
InstallShield 13:55:59: Processing XPath '//CompanyLicense/licenses'
InstallShield 13:55:59: Processing XPath '//CompanyLicense/licenses/add[licensekey=[LICENSEKEY]]'
InstallShield 13:55:59: XPath '//CompanyLicense/licenses/add[licensekey=[LICENSEKEY]]' not found, creating
InstallShield 13:55:59: Checking XPath 'CompanyLicense/licenses'
InstallShield 13:55:59: Creating element: Name=add, Namespace=
InstallShield 13:55:59: Node name: 'add' --> Attribute name = 'licensekey', Current Value = '', Operation = '1'
InstallShield 13:55:59: Node name: 'add' - Attribute name = 'licensekey', Old Value = '', New value = 'company=;address1=;address2=;address3=;contact=;exp_date=2011-12-24;issue_date=2011-10-25;modules=BaseServer;type=Trial;signature=Gysr+8XJD7D4TYVObfgONYhedTyCZDM9U8vVGc31bguTk2TWF7AI/g==;', Actual New Value = 'company=;address1=;address2=;address3=;contact=;exp_date=2011-12-01;issue_date=2011-10-25;modules=BaseServer;type=Trial;signature=Gysr+8XJD7D4TYVObfgONYhedTyCZDM9U8vVGc31bguTk2TWF7AI/g==;'
The result is like this
What am I doing wrong? or is this a bug in InstallShield?
Best regards,
Jens
(7) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 25, 2011
10:18 AM
Looking at this log statement
Processing XPath '//CompanyLicense/licenses/add[licensekey=[LICENSEKEY]]'
it seems it is searching for 'add[licensekey=[LICENSEKEY]]' rather than just 'licensekey'. That could be the issue.
Processing XPath '//CompanyLicense/licenses/add[licensekey=[LICENSEKEY]]'
it seems it is searching for 'add[licensekey=[LICENSEKEY]]' rather than just 'licensekey'. That could be the issue.
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)
Not applicable
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 25, 2011
10:39 AM
Yes, you are right, but my xml file can contain more than one licensekey.
The way you describe, it will not update anything if just one licensekey is present. I only want it, not to update, if exactly the same licensekey is present.
The way you describe, it will not update anything if just one licensekey is present. I only want it, not to update, if exactly the same licensekey is present.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 25, 2011
11:20 AM
Is this Basic MSI or pure InstallScript or InstallScript MSI project? I am doing something similar in my project, I have an InstallSCript MSI. The way I do it is I have an InstallScript method that takes two parameters, key and value.
I call it when the web.config is installed (Web_Installed event)..
It searches the XML file (web.config) for the key, if the key is found, it will assign the value. In your case, I would modify this function to check the current value, if it is same as the argument passed, do nothing. On the other hand, if the value is empty or different, or if no key is found, assign the value to the key. If this sounds like what you might need, let me know, I can send you the code I wrote.
I call it when the web.config is installed (Web_Installed event)..
It searches the XML file (web.config) for the key, if the key is found, it will assign the value. In your case, I would modify this function to check the current value, if it is same as the argument passed, do nothing. On the other hand, if the value is empty or different, or if no key is found, assign the value to the key. If this sounds like what you might need, let me know, I can send you the code I wrote.
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)
Not applicable
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 26, 2011
03:04 AM
Its a basic MSI, but im already using installscript, so it would be nice to get that code. It would not be nice to have the same xml nodes 10 times after 10 updates
Can it be categorized as a bug in IS 2011?
Will you add the code in here or should I send you a PM with my email address?
Best regards,
Jens
Can it be categorized as a bug in IS 2011?
Will you add the code in here or should I send you a PM with my email address?
Best regards,
Jens
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 26, 2011
10:43 AM
Jens,
Since putting out just one method may have been confusing, I put together a quick dirty sample to help you out. Please take a look at the attached zip file
. It has only one file, a web.config and the config file has just one node 'LicenseKey' with initial value '123456'. The installer installs this file and then updates the LicenseKey to '99999'.
I have built it with InstallShield 2012 Pro version, if you are still on 2011 and for some reason this doesn't open either open the two .Rul files (Setup and FeatureEvents) in notepad to see the code or download the trial version of 2012 Pro just to try it out. I am not using any 2012 specific features so it should technically run in older version.
Let me know if you have any questions.
Since putting out just one method may have been confusing, I put together a quick dirty sample to help you out. Please take a look at the attached zip file
I have built it with InstallShield 2012 Pro version, if you are still on 2011 and for some reason this doesn't open either open the two .Rul files (Setup and FeatureEvents) in notepad to see the code or download the trial version of 2012 Pro just to try it out. I am not using any 2012 specific features so it should technically run in older version.
Let me know if you have any questions.
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)
Not applicable
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 27, 2011
01:08 AM
Hi. Thanks a lot for your help.
I will look at it later today.
Best regards,
Jens
I will look at it later today.
Best regards,
Jens
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 02, 2013
10:36 AM
skolte wrote:
Is this Basic MSI or pure InstallScript or InstallScript MSI project? I am doing something similar in my project, I have an InstallSCript MSI. The way I do it is I have an InstallScript method that takes two parameters, key and value.
I call it when the web.config is installed (Web_Installed event)..
It searches the XML file (web.config) for the key, if the key is found, it will assign the value. In your case, I would modify this function to check the current value, if it is same as the argument passed, do nothing. On the other hand, if the value is empty or different, or if no key is found, assign the value to the key. If this sounds like what you might need, let me know, I can send you the code I wrote.
Can you send the code? I am having a MSI where i need to add a node when the user changes the input value in maintainance mode. I think your script might help me
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)