title: Why is OuterXml not producing a string value after modifying XML
body: <p>I have the below Powershell code where, when executed, the <code>$b4</code> has a string value, but once I modify the DOM in any way and try to access XmlDocument properties, such as OuterXml, I get no value in <code>$after</code>.</p>
  
  <p>I believe this is some type of casting issue but, I cannot determine the cause.  </p>
  
  <pre><code>$xml = [xml]"&lt;root&gt;&lt;/root&gt;"
  $comment = $xml.CreateComment("&lt;!-- added from comment --&gt;" )
  $b4 = $xml.OuterXml #this has a value as expected
  $xml.FirstChild.AppendChild($comment)
  $after = $xml.OuterXml  #This is empty string or null
  </code></pre>
  
  <p>How can I get the OuterXml value of $xml after modifying the DOM?</p>