powershell修改一个xml文件的某个节点的值,求脚本。
è¿æ¯ä¸ªå®ä¾ï¼ä¸ç¥éæ¯å¦è½å¸®å©å°ä½ ï¼
$doc=new-object System.xml.XmlDocument
$doc.load("C:\Program Files\BitComet\Downloads.xml")
$doc.BitComet.TaskList|%{$_.Torrent}|?{!$_.AutoRun}|%{$_.SetAttribute("AutoRun","true")}
$doc.BitComet.Torrents|%{$_.Torrent}|?{!$_.AutoRun}|%{$_.SetAttribute("AutoRun","true")}
$doc.save("C:\Program Files\BitComet\Downloads.xml")追é®
$doc=new-object System.xml.XmlDocument
$doc.load("C:\Program Files\BitComet\Downloads.xml")
$doc.BitComet.TaskList|%{$_.Torrent}|?{!$_.AutoRun}|%{$_.SetAttribute("AutoRun","true")}
$doc.BitComet.Torrents|%{$_.Torrent}|?{!$_.AutoRun}|%{$_.SetAttribute("AutoRun","true")}
$doc.save("C:\Program Files\BitComet\Downloads.xml")追é®
第3,4å¥ç管éä¸æã第äºå¥ loadå°±åºé
追çæåºéä¿¡æ¯è´´åºæ¥å§ãæè
æxmlæ件贴åºæ¥ï¼è¦æä¹ä¿®æ¹ä»ä¹ï¼
æç»ä½ ååºå®ä¾ã
133.0.23.76è¿ä¸ªååparam.xml ç¨ä¸ä¸ªpowershellèæ¬ä¿®æ¹ãç®çæ¯å¨å±åç½å广åç½ä¹é´åæ¢ã
追ç"133.0.23.76"|Out-File test.xml
$doc=new-object System.xml.XmlDocument
$doc.load("test.xml")
$doc.Root.var_ServerIp="111.111.111.111"
$doc.save("test.xml")
以ä¸æ¯ä»£ç ï¼ä»¥ä¸æ¯éªè¯
gc test.xml
111.111.111.111
温馨提示:答案为网友推荐,仅供参考