title: Web.config transforms - surrounding elements
body: <p>I am using the web.config transforms available via VS2010. In this one case I'm wondering if it possible to 'surround' an element with another during transformation. Here is an example:</p>
  
  <p>default web.config contains:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;system.web&gt;
     ....
    &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>My transformed file should contain</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;location inheritInChildApplications="false"&gt;
      &lt;system.web&gt;
      ...
      &lt;/system.web&gt;
    &lt;/location&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>So essentially I want to 'wrap' the system.web element with a location element. My only thought was to do a transform so that I inserted before and after like:</p>
  
  <pre><code>&lt;location inheritInChildApplications="false" 
            xdt:Transform="InsertBefore(/configuration/system.web)"&gt;
  &lt;/location xdt:Transform="InsertAfter(/configuration/system.web)"&gt;
  </code></pre>
  
  <p>But the closing location element isn't valid xml according to VS (I'm guessing because of the Transform attribute). Just inserting a self-closing location element before system.web doesn't help either because the resulting system.web is still not 'surrounded'. </p>