4

I have an XML file which has UTF-8 BOM marker(EF BB BF) at the beginning.

It also contains encoding as <?xml version="1.0" encoding="UTF-8" ?>.

I am trying to load this XML file using IXMLDOMDocument::LoadXML which fails to load this document. If I remove the BOM marker it works perfectly.

My question is it wrong to have the BOM marker in this case or is it a bug with MSXML (MSXML6 to be precise)?

Asha
  • 11,002
  • 6
  • 44
  • 66
  • 1
    Did you check this? : http://stackoverflow.com/questions/2109767/msxmls-loadxml-fails-to-load-even-well-formed-xml maybe helpful – rkosegi Mar 08 '12 at 08:38

1 Answers1

5

The IXMLDOMDocument::loadXML method expects a BSTR, which is UTF-16 encoded. See this page for a discussion of the issue.

I suggest to use IXMLDOMDocument::load instead, which has various overloads which don't require UTF-16.

Frerich Raabe
  • 90,689
  • 19
  • 115
  • 207