所以我正在学习如何使用PowerShell处理xml文档。现在我只是想改变一个给定的节点,然后保存更改。我目前被困在如何保存我的更改。使用powershell更改和xml文档,然后保存
这是我的。
$xmlfile = "testFile.xml"
$xml = [xml](get-content $xmlfile)
$employee = $xml.employees.employee
$employee[1].name = "New Name" // this is where I change the content of the xml file
//is this an okay way to change the value of the element??
$xml.save($xmlfile) //why wouldn't this line save my changes??
感谢您的帮助:)
我觉得我的脚本写的问题是,我的保存命令已经将我的文件保存到'home'而不是当前的工作目录--- http://stackoverflow.com/questions/4822575/saving-an-xml- file-in-powershell-requires-complete-path-why – Jeff 2012-03-29 22:02:10