【发布时间】:2012-03-30 06:00:44
【问题描述】:
所以我正在学习如何使用 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而不是当前工作目录---stackoverflow.com/questions/4822575/…
标签: xml powershell