Saving XML in UTF-8 with MSXML
- by stung
I'm trying to load a simple Xml file (encoded in UTF-8):
<?xml version="1.0" encoding="UTF-8"?>
<Test/>
And save it with MSXML in vbscript:
Set xmlDoc = CreateObject("MSXML2.DOMDocument.6.0")
xmlDoc.Load("C:\test.xml")
xmlDoc.Save "C:\test.xml"
The problem is, MSXML saves file in ANSI instead of UTF-8 (despite the original file being encoded in UTF-8).
The MSDN docs for MSXML says that save() will write the file in whatever encoding the XML is defined in but this is clearly not working at least on my machine.
How can MSXML save in UTF-8?