amaters
Posts: 4
Joined: Fri Mar 22, 2013 10:12 am

alter XML file content based on radiobox in dialog

Is it possible, and if so how, to alter an xml file based on choices the user makes during installation?

I have a large XML file with 2 main nodes. During installation the user can choose between 2 values which are directly linked to these 2 nodes.
Can I use the XML editor in Advanced Installer for this?
We are using the Enterprise edition.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: alter XML file content based on radiobox in dialog

Hello,

In order ro achive what you want you can take a look on our "Import and edit a XML file" article which should be useful for you.

Let us know if this helps, otherwise give us more details about your scenario.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
amaters
Posts: 4
Joined: Fri Mar 22, 2013 10:12 am

Re: alter XML file content based on radiobox in dialog

Thank you for the pointer but I already checked that one out. We already use the import XML feature. Maybe I am missing something here but I did not find anything regarding the removal of XML nodes.
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: alter XML file content based on radiobox in dialog

I am sorry, I don't understand exactly what you are trying to achive. Daniel pointed out correctly how to write something in the XML at install time based on the user's option.

What do you mean by the removal of XML nodes?

Best regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
amaters
Posts: 4
Joined: Fri Mar 22, 2013 10:12 am

Re: alter XML file content based on radiobox in dialog

Maybe I just need to figure out the correct way to do this...

In the installer the use has to select between two choices. option A and optoin B
if the user chooses option A the next screen will ask for some values.
if the user chooses option B the next screen will ask for some other values.

the XML we have is this:

<Config>
<add type="OptionA">
<attribute name="value1" value="[PROPERTY1]"/>
<attribute name="value2" value="[PROPERTY1]"/>
</add>
<add type="OptoinB">
<attribute name="value3" value="[PROPERTY3]"/>
<attribute name="value4" value="[PROPERTY4]"/>
</add>
</Config>

The above xml is simplified but the structure is exactly how it should be...
What I want to achieve is this:
if the user selects option A the node <add type="optionB"> has to be removed

I hope its more clear now
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: alter XML file content based on radiobox in dialog

Hello,

In order to achieve this you can try the following workaround:
- Go to "Files and Folders" page and add your XML file (e.g. myfile.xml) as a regular file (using [Add Files] toolbar button).
- Under myfile.xml containing folder create two sub-folders and from their "Edit Folder -> Properties" tab enable the "Install folder content into the parent folder" option.
- Select the first sub-folder and create a new XML file (having the same name as your myfile.xml), using the [New XML File] toolbar button, containing the "OptionA" element:
<add type="OptionA">
<attribute name="value1" value="[PROPERTY1]"/>
<attribute name="value2" value="[PROPERTY1]"/>
</add>
- Select the new created XML file and press "F8" key shortcut.
- In the "Condition" field, from "Component Properties" right pane, of the containing file component use a condition like this:

Code: Select all

USER_A_PROP
- Select the second sub-folder and create a new XML file (having the same name as your myfile.xml), containing the "OptionB" element:
<add type="OptionB">
<attribute name="value3" value="[PROPERTY3]"/>
<attribute name="value4" value="[PROPERTY4]"/>
</add>
- Select the new created XML file and press "F8" key shortcut.
- In the "Condition" field of the containing file component use a condition like this:

Code: Select all

USER_B_PROP
- Build and run your project.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
AnneTheAgile
Posts: 61
Joined: Wed Jun 08, 2011 9:53 pm

Re: alter XML file content based on radiobox in dialog

I think , Daniel, that your code for the substitution files should include the parent node element, config, right? The OP wanted to remove the other option, so that seems necessary. In other words, for Option A;

Code: Select all

<Config>
<add type="OptionA">
<attribute name="value1" value="[PROPERTY1]"/>
<attribute name="value2" value="[PROPERTY1]"/>
</add>
</Config>
Cross-Ref;
http://www.advancedinstaller.com/forums ... f=2&t=4115
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: alter XML file content based on radiobox in dialog

Hello Anne,

Yes, this is true.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”