XML : replacing text in multiple elements in an XML file

I have multiple endpoints in an XML doc where I am trying to replace some of the address strings. I don't want to replace the same text in the entire doc just in the endpoints. So I have tried to narrow it down and tried different ways but I cannot get it to work.

This is my most recent attempt. Am I missing something incredibly obvious here?

  $xmlDoc = [XML](Get-Content "$path\filename.exe.config")    foreach ($i in $xmlDoc.configuration.'system.serviceModel'.client.endpoint) {    if ($i.address -match "bla") {      $i.address -replace "bla", "foo"    }  }    $xmlDoc.Save("$path\filename.exe.config")    

No comments:

Post a Comment