I donβt know what exactly you want to achieve, but the example should give you an 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 do not need to use .NET for xpath requests. Just stay with PowerShell (with Select-Xml ).
Also, the xml file is usually downloaded via Get-Content and discarded by [xml] , which creates an XmlDocument and loads the contents of the file.
stej Jul 08 '10 at 14:17 2010-07-08 14:17
source share