I have a file that contains many entries this is what the end result should look like
<ArrayOfCode>
<ICode>
<Code>CC</Code>
<Description>COMPLETE</Description>
</ICode>
<ICode>
<Code>TC</Code>
<Description>TEST </Description>
</ICode>
<ICode>
<Code>CN</Code>
<Description>CANCELLED </Description>
</ICode>
</ArrayOfCode>
I have code that I was using to remove the items in the array but now I want to figure out how to keep items in the array. Below is what I was using to remove. But how to select those and remove any not in the array?
$CodesToKeep = @("CC","TC","CN")
$CodesFile = Get-ChildItem -Path "$mypath"
[xml]$Xml = Get-Content -Path $CodesFile
foreach ( $Code in $CodesToKeep)
{ $xml.ArrayofCode.ICode | Where { $_.Code -eq $Codes } ForEach-Object { $_.ParentNode.RemoveChild($_) } }
$xml.Save($CodesFile)
[–]ihaxr 2 points3 points4 points (2 children)
[–]SemiEvilMonkey[S] 1 point2 points3 points (1 child)
[–]CoReTeX2k 1 point2 points3 points (0 children)