user1877936
user1877936

Reputation: 363

How to update the xml attribute values using powershell

I am passing $SourceFileName as studentpackage.zip and copying the zip to below two location.how to update the xml attribute configsolutionfile when there is a change in $SourceFileName

function BuildArchive          
{            
    param            
    (            
        [parameter(Mandatory=$true)]            
        [ValidateNotNullOrEmpty()]             
        [String] $SourceFileName = ""                                                    
    )  
}

D:\StudentProgram\Automate\Publishing\Content\Forums\StudentPackage contains an xml file where I need to update the attribute configsolutionfile

<?xml?>
<config>
  <solutions>
    <configsolutionfile solutionpackagefilename="studentpackage.zip" />
  </solutions>
</config>

D:\StudentProgram\Automate\Publishing\Content\Archives\StudentPackage contains an xml file where I need to update the attribute configsolutionfile

<?xml?>
<config>
  <solutions>
    <configsolutionfile solutionpackagefilename="studentpackage.zip" />
  </solutions>
</config>

Upvotes: 0

Views: 113

Answers (1)

Vish
Vish

Reputation: 466

You can do this:

[xml]$xml_contents = Get-Content 'path to XML'
$xml_contents.config.solutions.configsolutionfile.solutionpackagefilename = 'test'
$xml_contents.Save('Path to new XML')

Upvotes: 2

Related Questions