I'm using the following PowerShell to update the value of an element in some XML which works fine, but when I save the XML it appears to change the formatting.
$xmlFileName = "D:\scripts\DbRestoreDIFF.xml"
[xml]$xmlDoc = Get-Content $xmlFileName
$xmlDoc.TMMsg_CreateTaskReq.taskInfo.subTasks.options.restoreOptions.browseOption.timeRange.toTimeValue = $Timestamp
$xmlDoc.Save($xmlFileName)
After I save the document there are several elements where the format goes from:
<alert>
<alertName></alertName>
</alert>
to:
<alert>
<alertName>
</alertName>
</alert>
I've tried preserving whitespace but it didn't seem to help. This is causing me an issue as I'm them unable to pass the XML correctly.
_pass the XML correctly_? What issues are cause by this?