title: Updating XML node even if it's empty
body: <p>I've got the following powershell code that updates xml nodes with values from Octopus Deploy.</p>
  
  <pre class="lang-posh prettyprint-override"><code>    foreach($key in $OctopusParameters.Keys)
      {
          $myXPath = "$nodeXPath/$($key.Replace(".", "/"))"
          try{
              $node = $doc.SelectSingleNode($myXPath)
          } catch { &lt;# sometimes Octopus passes in crappy data #&gt; }
          if($node){
              Write-Host "Overriding node: '$key'`t`t With value: $($OctopusParameters["$key"])"
              $node.'#text' = $OctopusParameters["$key"]
          }
      }
  </code></pre>
  
  <p>It's working great, but only if the original xml node has a value.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;something&gt;Replaced_by_octopus&lt;/something&gt;  &lt;!-- I work --&gt;
  &lt;something&gt;&lt;/something&gt;                     &lt;!-- I fail --&gt;
  </code></pre>
  
  <p>The failure is on the line <code>$node.'#text' = $OctopusParameters["$key"]</code> with the following error message</p>
  
  <blockquote>
    <p>Get-EnvironmentSettings : Exception setting "#text": "The property '#text' cannot be found on this object. Verify that 
    the property exists and can be set."</p>
  </blockquote>
  
  <p>What do I need to do to be able to update that node regardless of if it's empty or not?</p>