Conditional replace in XML files
问题 I'm replacing a text in XML files recursively using PowerShell. The script is working fine in replacing. However the XML files also have file paths which should not be replaced. This is the script currently being used if ( $content -match ' web site | web-site ' ) { $content -replace ' web site ',' New Site ' -replace ' web-site ',' New Site ' | Out-File $file.FullName -Encoding utf8 For example if the XML file has <title>web site</title> <subtitle>web-site</subtitle> <path>c:/web site