title: Change XML Element value with PowerShell
body: <p>I'm only finding stuff on how to change the attribute values of a XML element here on StackOverflow. </p>
  
  <p>But how do we change the value of the element itself using PowerShell? </p>
  
  <p>I currently have:</p>
  
  <p><strong>XML</strong></p>
  
  <pre><code>&lt;Task&gt;
    &lt;Settings&gt;
    ...
    &lt;/Settings&gt;
    &lt;Actions Context="Author"&gt;
      &lt;Exec&gt;
        &lt;Command&gt;blablabla&lt;/Command&gt;
        &lt;Arguments&gt;CHANGETHISVALUE&lt;/Arguments&gt;
      &lt;/Exec&gt;
    &lt;/Actions&gt;
  &lt;/Task&gt;
  </code></pre>
  
  <p><strong>SCRIPT</strong></p>
  
  <pre><code>$filePathToTask = C:\Task.xml
  $xml = New-Object XML
  $xml.Load($filePathToTask)
  $element =  $xml.SelectSingleNode("//Arguments")
  $element.InnerText("newtext")
  $xml.Save($filePathToTask)
  </code></pre>
  
  <p>However, I can't seem to use methods on the last variable. What am I doing wrong?</p>
  
  <p><strong>Edit</strong></p>
  
  <ul>
  <li>Added code </li>
  </ul>
  
  <p>The error that I'm getting is <em>You cannot call a method on a null-valued expression</em></p>
  
  <p>I think my problem lies at:</p>
  
  <pre><code>$ElementToChange =  $xml.SelectSingleNode("//Arguments")
  </code></pre>
  
  <p>Which stays null, but I have tried methods like <code>.SelectNodes</code> and playing around with the <code>//Arguments</code>tag but still no success</p>