Copy from one xml file to another - powershell

nenteepay

New Member
Zdravo!Now this one has been bugging me quite a lot... I'm trying to copy a couple of nodes from one XML file to another using powershell, and looked around the whole internets, but it seems that only on my pc the universal solution to the problem is not working. So this is the code I've got now:\[code\]#loading one document$xml = New-Object XML$xml.Load("C:\Inetpub\WWWroot\web.config")#load another$wconfig = New-Object XML$wconfig.Load("C:\Users\foo\test.enc")#now do what everyone on the internet says$xml.DocumentElement.InsertAfter($wconfig.ImportNode($wconfig.SelectSingleNode($node), $true), $afterNode))\[/code\]Anyone got any idea why this (and a couple of other alternatives like .Clone()) always return "The node to be inserted is from a different document context." Or just give me another alternative. Anything that works :DThanks
 
Back
Top