Discussion:
Why no BOM when saving XML document?
(too old to reply)
oskar
2006-08-23 07:59:02 UTC
Permalink
Hi,

Using Msxml2.DOMDocument.4.0 in VBScript (a .wsf-file).

I'm loading an xml document with '<?xml version="1.0" encoding="utf-8"?>'
declared.

I'm modifying it in the code, adding some nodes etc.

Then save it to another file using xmlDoc.save( "doc.xml").

Looking at the saved file in an HEX editor shows that the BOM (Byte Order
Mark) for UTF-8 is not there. If I open the xml file in notepad and save it
again, the BOM is added.

So, my question is, why is the BOM not added to the xml file when using the
save-method?

Thanks,
Oskar
Martin Honnen
2006-08-23 11:10:57 UTC
Permalink
Post by oskar
Looking at the saved file in an HEX editor shows that the BOM (Byte Order
Mark) for UTF-8 is not there. If I open the xml file in notepad and save it
again, the BOM is added.
So, my question is, why is the BOM not added to the xml file when using the
save-method?
The BOM for UTF-8 is optional. UTF-16 always needs one.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Continue reading on narkive:
Search results for 'Why no BOM when saving XML document?' (Questions and Answers)
10
replies
Is Global Warming Inevitable? H.W HELP!?
started 2007-03-12 18:26:24 UTC
environment
Loading...