I have this XML file: environment-config.xml
<?xml version="1.0" encoding="windows-1252"?>
<environment>uat</environment>
I would like to update the value and have this script.
[string]$EnvConfigFileName = ".\environment-config.xml"
$EnvironmentName = 'prod'
[XML]$xmlFileContent = Get-Content $EnvConfigFileName
$xmlNode = $xmlFileContent.SelectSingleNode("/environment")
$xmlNode.Value = $EnvironmentName
$xmlFileContent.Save($EnvConfigFileName)
On execution it generates this error: Exception setting "Value": "Cannot set a value on node type 'Element'." ---> System.InvalidOperationException: Cannot set a value on node type 'Element'.
Is there another way to do this?
Thanks in advance.