guidogast
Posts: 51
Joined: Thu Sep 05, 2013 10:12 am

Remove certain tags from XML based on conditions

Hello,

We have a XML file(Windows Installer Format) with 5 tags inside. We need to remove 1 or more tags based on certain conditions. My colleague tried to achieve this by creating folders with conditions and install the content in the parent folder, but there are a lot of combinations possible. So does this mean that my colleague needs create lots of folders to achieve this, or is there another, more fast way to take care of this?

Thanks in advance!

Sincerely,
Guido
Eusebiu
Posts: 4959
Joined: Wed Nov 14, 2012 2:04 pm

Re: Remove certain tags from XML based on conditions

Hi Guido,

In order to remove tags conditionally on install in an easier way, you can follow the steps below:
- create an "XML Edit" file for each tag (5 in your case), place them in different subfolders and install them in the parent folder
- each XML file will contain only the "path" to the element that should be removed and its attributes
- go in the "Attributes" tab and edit the attribute that you want to remove like below:
  • Name: <attribute name>
    Value: (not important)
    Operation: Remove
    Execute update: on install
- install each XML based on a condition
- build and run the project

In this case if only one condition is true, only one element will be removed, if more conditions are true, more elements will be removed.

However, this workaround does not remove the attribute completely, only its value will be removed and this may be acceptable or not depending on your application's requirements.

Another workaround (maybe better) would be to create "Text File Updates" instead of "XML Edit" files and install them based on the same conditions. A "Text File Update" would be configured to search for:

Code: Select all

<specific_tag>....</specific_tag>
and replace it with

Code: Select all

[EMPTY_PROPERTY] (you can use the name of a property that does not exist)
Let us know if this helped.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
guidogast
Posts: 51
Joined: Thu Sep 05, 2013 10:12 am

Re: Remove certain tags from XML based on conditions

My colleague tested this and it works now.

Thanks!

Sincerely,
Guido
Eusebiu
Posts: 4959
Joined: Wed Nov 14, 2012 2:04 pm

Re: Remove certain tags from XML based on conditions

You're welcome. I'm glad you got this working.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”