¿Cómo puedo cambiar el valor del nodo <Test>Test</Test>
a <Test>Power</Test>
?¿Cómo puedo actualizar el valor de un nodo XML utilizando PowerShell?
Ejemplo:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="DeploymentDate" value="test" />
<add key="DateOfInitialization" value="Vinoj" />
</appSettings>
<Test>Test</Test>
</configuration>
Aquí está el script de PowerShell que uso actualmente:
$configuration = "app.config"
[xml]$xml = New-Object XML
$xml.Load($configuration)
$xml.selectnodes("/configuration/Test") = {"UST"}
$xml.Save($configuration)
Funcionó como un encanto. ¿Puedes decirme qué? % lo hace en general? –
Significa 'foreach-object'. Puede encontrarlo con 'Get-Alias -Name%' – stej
, también puede acceder al valor de prueba '$ xml.configuration.test' - Pretty slick (dado que no es una colección) pero luego puede usar' foreach ($ thing in $ xml.things) {$ thing.value} '. Estoy aquí porque necesito guardar mi archivo XML después de incrementar la versión. Y esto me ayudó. +1 – ppumkin