Question:
I need to edit a .xml file with powershell. The thing I need to do is to download the .xml file from the server, updated the version number, and then save it in my local computer. This is what I did.
1 2 3 4 |
[xml]$myXML = get-content $xmlFileServer $myXML.'ivy-module'.info.revision = $newVersion $myXML.Save($newXMLFileName) |
Then I will have a new xml file in my local computer. However, I doubt the coding is different since I can’t process with this .xml file.
The .xml I should get is something like this:
1 2 3 4 5 6 7 8 |
However, after editing with powershell, the .xml contains some hidden info. I tried to open with NotePad++, I got something like this:
1 2 3 4 5 6 7 8 |
 |
Can anyone tell me why is the situation?
Thank you so much.
Answer:
“” is the Byte Order Mark for UTF-8. There is a solution for writing a UTF-8 file without the BOM here:
Using PowerShell to write a file in UTF-8 without the BOM