Saving XML in UTF-8 with MSXML

Posted by stung on Stack Overflow See other posts from Stack Overflow or by stung
Published on 2010-04-07T21:31:12Z Indexed on 2010/04/07 21:33 UTC
Read the original article Hit count: 241

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about Xml

Related posts about msxml