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

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

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

XML:


  
    <         


        
3条回答
  •  抹茶落季
    2020-12-11 00:25

    if we are taking attribute from console and changing its value ?

    $path=Read-Host -Prompt 'Enter path of xml file'
    [xml]$xmldata = get-content "$path"
    
    $tag = Read-Host -Prompt 'Enter tag'
    $value = Read-Host -Prompt 'Enter value'
    $xmldata.InstallConfig.$tag="$value"
    $xmldata.Save($path)
    

提交回复
热议问题