title: Save XML adding space in blank fields
body: <p>So I'm trying to learn how to modify XML files with PowerShell but am encountering a weird issue, where PowerShell adds blank space to my XML files after saving them.</p>
  
  <p>Say I have an xml file called test.xml that looks like:</p>
  
  <pre><code>&lt;employee&gt;
      &lt;person&gt;
          &lt;name&gt;John Doe&lt;/name&gt;
          &lt;id&gt;&lt;/id&gt;
      &lt;/person&gt;
  &lt;/employee&gt;
  </code></pre>
  
  <p>I wrote this PowerShell script to change the name:</p>
  
  <pre><code>$file1 = ".\test.xml"
  $file2 = ".\test_new.xml"
  $xml = New-Object XML
  $xml.Load($file1)
  $xml.employee.person.name = "John Smith"
  $xml.Save($file2)
  </code></pre>
  
  <p>So far, so good. However, the output file is formatted like this:</p>
  
  <pre><code>&lt;employee&gt;
      &lt;person&gt;
          &lt;name&gt;John Smith&lt;/name&gt;
          &lt;id&gt;
         &lt;/id&gt;
      &lt;/person&gt;
  &lt;/employee&gt;
  </code></pre>
  
  <p>This is a problem, because I am trying to use similar code to update an XML file with a schema that restricts including spaces in blank fields. This makes it unreadable after modification.
  Anyone know what I'm doing wrong here?</p>