title: Removing whitespace in XElement closing tag
body: <p>I have some XML that I am building that looks like this:</p>
  
  <pre><code>&lt;actionitem actiontaken="none" target="0" targetvariable="0"&gt;
    &lt;windowname&gt;Popup Window&lt;/windowname&gt;
    &lt;windowposx&gt;-1&lt;/windowposx&gt;
    &lt;windowposy&gt;-1&lt;/windowposy&gt;
    &lt;windowwidth&gt;-1&lt;/windowwidth&gt;
    &lt;windowheight&gt;-1&lt;/windowheight&gt;
    &lt;noscrollbars&gt;false&lt;/noscrollbars&gt;
    &lt;nomenubar /&gt;
    &lt;notoolbar /&gt;
    &lt;noresize /&gt;
    &lt;nostatus /&gt;
    &lt;nolocation /&gt;
    &lt;browserWnd /&gt;
  &lt;/actionitem&gt;
  </code></pre>
  
  <p>This XML has to be to the exact specifications of the client, meaning I can't have a whitespace in the closing tag.  I know that MSDN says this: </p>
  
  <blockquote>
    <p>When writing an empty element, an additional space is added between tag name and 
    the closing tag, for example . This provides compatibility with older browsers.</p>
  </blockquote>
  
  <p>But, the client won't/can't budge on this.  So, I thought I could try something like this to remedy the problem:</p>
  
  <pre><code>xelement.ReplaceWith(" /&gt;", "/&gt;");
  </code></pre>
  
  <p>But when I run the program, I get this error message:</p>
  
  <pre><code>Non white space characters cannot be added to content.
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/dnKnK.png" alt="Error message"></p>
  
  <p>So, does anyone know how I can remove that white space once I've built the XML document?</p>