update xml nodes in powershell



I have an XML file that i need to update, however, when using this code



function SaveVersionNumber($Path, $Ver) {
[xml] $xml = Get-Content -Path $Path;
$info = $xml.versionInfos.versionInfo | where {$_.code -eq $Code}
$xml.Save($Path);
Write-Host "Saving $Path with " (Get-FormattedVersion $Ver);}

function UpdateRevision($ver) {
#$ver.build = [string] ([int] $ver.build + 1);
[xml] $xdoc.versionInfos.versionInfo[0].build
#return $ver;
return $xdoc;}

<?xml version="1.0" encoding="UTF-8">
<versionInfos>
<VersionInfo code="sc">
<major>1</major>
<minor>1</minor>
<build>1</build>
</versionInfo>
<VersionInfo code="scw">
<major>1</major>
<minor>1</minor>
<build>1</build>
</versionInfo>
<versionInfos>


it doesnt update the values on any of the information.


This was previously working with code


and XML looked like this



function SaveVersionNumber($Path, $Ver) {
$xml.Save($Path);
Write-Host "Saving $Path with " (Get-FormattedVersion $Ver);}

function UpdateRevision($ver) {
$ver.build = [string] ([int] $ver.build + 1);
return $ver;}

<?xml version="1.0" encoding="UTF-8">
<VersionInfo>
<major>1</major>
<minor>1</minor>
<build>1</build>
</versionInfo>


any and all help very much appreciated


No comments:

Post a Comment