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.
To prepare for this recipe, perform the following steps:
Create a new setup project and call it
RemoveElementInstaller
.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>
Add a
Component
element toProduct.wxs
to include the file in the install:<Component Id="cmpWebCONFIG" Guid="{1B527456-4367-4D3D-AAE4-7E5C22FB9192} <File Source="Web.config...