title: How to change the value of XML Element attribute using PowerShell?
body: <p>I am trying to access and change the particular attribute from XML tag </p>
  
  <p>XML:</p>
  
  <pre><code>&lt;office&gt;
    &lt;staff branch="Hanover" Type="sales"&gt;
      &lt;employee&gt;
          &lt;Name&gt;Tobias Weltner&lt;/Name&gt;
          &lt;function&gt;management&lt;/function&gt;
          &lt;age&gt;39&lt;/age&gt;
      &lt;/employee&gt;
      &lt;employee&gt;
          &lt;Name&gt;Cofi Heidecke&lt;/Name&gt;
          &lt;function&gt;security&lt;/function&gt;
          &lt;age&gt;4&lt;/age&gt;
      &lt;/employee&gt;
    &lt;/staff&gt;
    &lt;staff branch="London" Type="Technology"&gt;
     &lt;employee&gt;
      &lt;Name&gt;XXXX&lt;/Name&gt;
      &lt;function&gt;gement&lt;/function&gt;
      &lt;age&gt;39&lt;/age&gt;
  </code></pre>
  
  <p>From the above example I want to print  branch attribute and then want to change it with one value such as New York in all the whole XML and using below code to do that</p>
  
  <pre><code>       $xml=New-Object XML
  
        $xml.Load("C:\FE6Work.xml")
  
        $node=$xml.SelectNodes("/office/staff")
  
        write-output $node.branch
        $node.branch="New York"
  </code></pre>
  
  <p>But get an error stating can't find the element.</p>
  
  <p>Can someone please help?</p>