I need to update one line in xml and save changes. It looks ease but it doesn't work for me and I cannot find my mistake ( So, I need help. It is my code:
[xml]$XmlDocument = Get-Content -Path "C:\Users\Administrator\Documents\Practise\Test.xml"
$random = -join ((48..57) + (97..122) | Get-Random -Count 16 | % {[char]$_})
$node = $XmlDocument.Payment.PaymentOptions.Bank.Value5
$node = $node.Replace('13384wL839', $random)
$XmlDocument.Save("C:\Users\Administrator\Documents\Practise\Test.xml")
there is my xml:
<Payment xmlns="2.0.0">
<PaymentValue1>
<value1>180.00</value1>
<value2>2017-09-30</value2>
<value3>022456789</value3>
</PaymentValue1>
<PaymentOptions>
<Bank>
<Value4>Test1</Value4>
<Value5>13384wL839</Value5>
</Bank>
</PaymentOptions>
</Payment>
I see that $node is changed but when I save new xml - it is still old value is displayed.