XML : How to properly export XML to file using Powershell

Importing any valid XML file as source using [XML]$Var = Get-Content -Path $PathToAnyValidXML I am unable to export it's content properly.

Using Set-Content SomePath $Var , the file ends with System.Xml.XmlDocument as content.

Using $Var | Export-Clixml SomePath , the file ends with the original XML inside an XML

What is a correct method to write raw XML to a file properly ? (Get the exact same content that was on $PathToAnyValidXML once it was imported to a variable on Powershell)

If we need to use XPath or Objects, provide example with both method if possible.

No comments:

Post a Comment