Read and Edit XML content and get output to an XML variable in PowerShell

nasyharlers

New Member
I have an XML file content similar to the following:\[code\]<?xml version="1.0" encoding="utf-8"?><Content> <FileID>109F2AEA-6D9C-4127-963A-9C71D4155C5D</FileID> <File Path="C:\test.config"> <Tag TagName="configuration"> <add Content="One" fileID="${FileID}"/> <secondnode Content="Two" fileID="${FileID}"> <nodeinside> <inneragain fileID="${FileID}"/> </nodeinside> </secondnode> ... <diffentnode Content="Infinite" fileID="${FileID}"/> </Tag> </File></Content>\[/code\]I just need to get this XML file content and edit (replacing whereever ${FileID} is present) the lines as shown below\[code\]<add fileID="${FileID}"/>\[/code\]using the value of the "FileID" from the following line and get the output to a variable of DataType [xml].\[code\]<FileID>109F2AEA-6D9C-4127-963A-9C71D4155C5D</FileID>\[/code\]Please suggest the best way this can be done in PowerShell.
 
Back
Top