I'm trying to change a specific element of an XML. I have the following XML File:
<?xml version="1.0" encoding="utf-8"?>
<recording-event>
<video hashType="none">
<streams>
<stream num="1" start-tick="01234567890" stop-tick="02134567890">
<file name="FileName.mp4" hashCode="123456789" />
<file name="FileName.vtt" hashCode="987654312" />
<file name="FileName.json" hashCode="10111213" />
</stream>
</streams>
</video>
</recording-event>
I'm trying to change:
<file name="FileName.mp4" hashCode="123456789" />
to
<file name="FileName.mp4" hashCode="ChangingTest" />
I've come up with the following script to access this element, but I can't seem to figure out who to change it.
Here is the powershell script i'm currently using:
[xml]$content = Get-Content "C:\Users\WG\Desktop\test.xml"
$content.'recording-event'.video.streams.stream.file.hashCode.Item(0)
$content.'recording-event'.video.streams.stream.file.hashCode.Item(0) = 'ChangingTest'
$content.'recording-event'.video.streams.stream.file.hashCode.Item(0)
$content.Save('C:\Users\WG\Desktop\test.xml')
I'm not sure what I'm missing here, but would appreciate any direction/resources I may have missed on this.