Update XML element
<p>Given the following XML:</p>

<pre class="lang-xml prettyprint-override"><code>&lt;data&gt;  
   &lt;variable&gt;
    &lt;row&gt;
      &lt;column1&gt;RPS&lt;/column&gt;
      &lt;column2&gt;10&lt;/column&gt;
    &lt;/row&gt;  
  &lt;/variable&gt;

  &lt;variable&gt;
    &lt;row&gt;
      &lt;column1&gt;SANTH&lt;/column&gt;
      &lt;column2&gt;5000&lt;/column&gt;
    &lt;/row&gt;  
  &lt;/variable&gt; 
&lt;/data&gt;
</code></pre>

<p>I need to read the value 5000 and need to replace with some random number. I am I not having any clue. Below code copied from net. It's not working as per my requirement.</p>

<pre class="lang-bsh prettyprint-override"><code>$variable = Get-Random

[xml]$xml = Get-Content D:\test.xml
$xml.data.variable.row.ChildNodes.Item(1)."#text" = "$variable" // failing  here 
$xml.Save('D:\test.xml')
</code></pre>

<p>Also, Plese let me know how to access the column2 by giving element name rather giving index value.</p>