Adding a new element to an XML file during installation
In this recipe, we'll learn how to add an element to an XML file. One place where this might be useful is to enable tracing in an ASP.NET web application. Tracing lets you see diagnostic information about a running web application. We'll start with a basic
Web.config file that doesn't have any tracing configuration in it and add a
trace element to set it up.
To prepare for this recipe, perform the following steps:
- Create a new setup project and name it
- So that we'll have something to modify, add an XML file to the project and call it
Web.config. Add the following markup to it:
<?xml version="1.0"?> <configuration> <appSettings /> <connectionStrings /> <system.web> ...