Powershell replace xml node values from one file to another -


powershell newbie here...

i have following xml files (2). 1 have data in , other format. i've seen articles on replacing 1 item in node can't see figure out loop or command update elements of node.

all have far loop , action of updating 1 file i'm stuck.

precursor: not looking consulting work or finish product in end. looking pointing places, commands etc, guide me end product.

[xml]$file1 = get-content file1.xml [xml]$file2 = get-content file2.xml  foreach($node in $file.checklist.asset.childnodes) {  $file2.checklist.asset.?localname?.value = $file1.checklist.asset.?localname?.value  } 

update...

example of file1.xml

<list> <asset>     <role>some role</role>     <asset_type>server</asset_type>     <host_name>my computer</host_name> </asset> 

example of file2.xml

<list> <asset>     <role></role>     <asset_type></asset_type>     <host_name></host_name> </asset> 

desired output of file2.xml

    <list> <asset>     <role>some role</role>     <asset_type>server</asset_type>     <host_name>my computer</host_name> </asset> 

this small portion of both files.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -