Im reading an xml file into powershell xml variable.
Originally I was modifying some values in the file, and saving it back out, but found the app that uses the file was discarding it as it found issues.
So if I read in the file, don't change anything but then save it as a new file, powershell changes the xml!
there are extra spaces and other things added.
One thing I notice its doing is for an empty element, it adds a space between the element and the forward slash.
e.g.
before save <element/>
after save <element />
Here is the code im using.
[xml]$fileContents = Get-Content -Path $XMLConfigFileLocation
$fileContents.Save($xmlWorkingFile)
This is causing a 3rd party app that uses the file to throw errors.
Im aware the 3rd party app probably is not processing the xml file correctly but i have no control over that.
Any ideas why powershell modifies the file?