I have an xml file where each element formatted like this:
<ScriptEvent xsi:type="Event">
<_time>0</_time>
</ScriptEvent>
<ScriptEvent xsi:type="Event">
<_time>1</_time>
</ScriptEvent>
<ScriptEvent xsi:type="Event">
<_time>2</_time>
</ScriptEvent>
<ScriptEvent xsi:type="Event">
<_time>3</_time>
</ScriptEvent>
I'm wondering how I can change the xml like this:
- We will have a variable "count", and this is the value we will use to replace the current "_time" element
- Every two ScriptEvent elements, this count will increase by one.
So for example, the expected output file will look like this:
<ScriptEvent xsi:type="Event">
<_time>0</_time>
</ScriptEvent>
<ScriptEvent xsi:type="Event">
<_time>0</_time>
</ScriptEvent>
<ScriptEvent xsi:type="Event">
<_time>1</_time>
</ScriptEvent>
<ScriptEvent xsi:type="Event">
<_time>1</_time>
</ScriptEvent>
I'm not very good with powershell, can someone help me think of a working powershell script for this? The xml file I have actually have a lot of these ScriptEvent elements (over 400k of them).
Thank you very much.