tags:

views:

170

answers:

1

How do you delete/remove an element from an XML file in WiX?

+2  A: 

Given a .config file with the following content:

<configuration>
 <thingy>
  <stuff>
   <item type='value' />
   <item type='value2' />
  </stuff>
 </thingy>
</configuration>

To remove the item element with the type attribute set to 'value' this seems to do the trick:

<util:XmlConfig
  On="install"
  Action="delete"
  Id="RemoveAnElement"
  Node="element"
  File="Application.dll.config"
  VerifyPath="/configuration/thingy/stuff/item[\[]@type='value'[\]]"
  ElementPath="/configuration/thingy/stuff"
  Sequence="100"
/>

This XmlConfig element is defined by the Wix "Utility" extension. To use that extension, you have to declare the UtilExtension namespace like this:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
   xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"&gt;

You also have to add -ext WixUtilExtension to the light.exe command options, or add a reference to "WixUtilExtension.dll" if you are authoring a wix project using votive in visual studio.

David Gardiner