title: Remove Whitespace From XML Nodes
body: <p>How can I remove whitespace on every instance of a particular node which I specify in C#? For example let's say that I have the following XML document:</p>
  
  <pre><code>&lt;XML_Doc&gt;
  
    &lt;Record_1&gt;
       &lt;Name&gt;Bob&lt;/Name&gt;
       &lt;ID_Number&gt;12345&lt;/ID_Number&gt;
       &lt;Sample&gt;
       &lt;/Sample&gt;
    &lt;/Record_1&gt;
  
    &lt;Record_2&gt;
       &lt;Name&gt;John&lt;/Name&gt;
       &lt;ID_Number&gt;54321&lt;/ID_Number&gt;
       &lt;Sample&gt;
       &lt;/Sample&gt;
    &lt;/Record_2&gt;
  
  &lt;/XML_Doc&gt;
  </code></pre>
  
  <p>What I would like is to take every instance of the <code>&lt;Sample&gt;</code> tag and change the formatting so it looks like this:</p>
  
  <pre><code>&lt;XML_Doc&gt;
  
    &lt;Record_1&gt;
       &lt;Name&gt;Bob&lt;/Name&gt;
       &lt;ID_Number&gt;12345&lt;/ID_Number&gt;
       &lt;Sample&gt;&lt;/Sample&gt;
    &lt;/Record_1&gt;
  
    &lt;Record_2&gt;
       &lt;Name&gt;John&lt;/Name&gt;
       &lt;ID_Number&gt;54321&lt;/ID_Number&gt;
       &lt;Sample&gt;&lt;/Sample&gt;
    &lt;/Record_2&gt;
  
  &lt;/XML_Doc&gt;
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The other application which makes use of the XML file was not written by me and I cannot modify the structure of the XML document itself. I am writing a utility which parses the XML file and replaces each instance of the node I specify. The example where the <code>&lt;Sample&gt;&lt;/Sample&gt;</code> tag is on the same line is how the document is originally formatted and how I need it to be for the other application to be able to read it correctly.</p>