Removing an XML element

In this recipe, we'll see how to remove an element from an XML document. You might use this when updating a shared configuration file that has a setting that no longer applies. We'll start out with a configuration file that has three add elements in it. During our installation, we'll remove the middle one.

Getting ready

To prepare for this recipe, perform the following steps:

  1. Create a new setup project and call it RemoveElementInstaller.
  2. Add an XML file named Web.config to the project and add the following markup to it:
    <?xml version="1.0"?>
    <configuration>
      <appSettings>
        <add key="UserSetting1" value="abc" />
        <add key="UserSetting2" value="def" />
        <add key="UserSetting3" value="ghi" />
      </appSettings>
    </configuration>
  3. Add a

Get WiX Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.