How to change the value of XML Element attribute using PowerShell?

前端 未结 3 662
南旧
南旧 2020-12-11 00:05

I am trying to access and change the particular attribute from XML tag

XML:


  
    <         


        
3条回答
  •  执笔经年
    2020-12-11 00:14

    Try the following:

    $nodes = $xml.SelectNodes("/office/staff");
    foreach($node in $nodes) {
        $node.SetAttribute("branch", "New York");
    }
    

    This will iterate through all nodes returned by SelectNodes() and modify each one.

提交回复
热议问题