Please help me create a Powershell script that will go through an XML file and update content. In the example below, I want to use the script to pull out and change the fil
Try this:
$xmlFileName = "c:\so.xml"
$match = "C:\\Prog\\Laun\.jar"
$replace = "C:\Prog32\folder\test.jar"
# Create a XML document
[xml]$xmlDoc = New-Object system.Xml.XmlDocument
# Read the existing file
[xml]$xmlDoc = Get-Content $xmlFileName
$buttons = $xmlDoc.config.button
$buttons | % {
"Processing: " + $_.name + " : " + $_.command
$_.command = $_.command -Replace $match, $replace
"Now: " + $_.command
}
"Complete, saving"
$xmlDoc.Save($xmlFileName)