Hello All,
I need to extract some records from an xml file based on some criteria and copy them to another file. I am just stuck on how to save the selected records to another file. grateful if you can help. find powershell script below.
$filelocation="C:\csv"$files = Get-ChildItem -Path $filelocation
[xml]$xml = get-content $filelocation\$file
foreach ($x in $xml.ips.MailItem)
{
$itemid=$x.ItemId
$itemidlength=$x.ItemId.Length
if ($itemidlength -eq 13)
{
$prefix=$x.ItemId.Substring(0,2)
$suffix=$x.ItemId.Substring(11,2)
if ($prefix -eq 'RP' -and $suffix -eq 'MU')
{
$xml.DocumentElement.AppendChild($x)
#stuck here
$xml.Save("C:\csv\test.xml")
}
}
}