How can I change the value of the node
to
?
Example
I don't know what exactly you want to achieve, but the example should give you and idea:
$file = 'c:\temp\aa\ServerService.exe.config'
$x = [xml] (Get-Content $file)
Select-Xml -xml $x -XPath //root/level |
% { $_.Node.'#text' = 'test'
$_.Node.SomeAttribute = 'value'
}
$x.Save($file)
You don't need to use .NET for xpath queries. Just stay with PowerShell (with Select-Xml
).
It is also common to load xml file via Get-Content
and cast it to [xml]
which creates XmlDocument
and loads the file content.