views:

3588

answers:

2
+13  A: 

It turns out, the answer is that what I'm seeing is a Byte Order Mark, which is a character that tells whatever is loading the document what it is encoded in. In my case, it's encoded in utf-8, so the corresponding BOM was EF BB BF, as shown below. To remove it, I opened it up in Notepad++ and clicked on "Encode in UTF-8 without BOM", as shown below:

Saving in NotePad++.

To actually see the BOM, I had to open it up in TextPad in Binary mode:, and conducted a Google search for "EF BB BF".

binary mode

It took me about 8 hours to find out this was what was causing it, so I thought I'd share this with everyone.

George Stocker
Yea, I've stubbed my toe on that one too. The XML parser we're using (in Java) doesn't like the UTF-8 BOM that windows editors like to produce. I wrapped InputStream to detect it and throw it away before passing the bytes on to the parser.
bendin
I hope that no poor soul has to spend any more time on this problem than I had to. It's ridiculous that at this day and age, Visual Studio doesn't say, "Gee, that looks like a BOM, maybe I'd better warn the programmer."
George Stocker
I cannot reproduce this either with VS2008 or VS2005. Which version of VS is causing the problem? Could you provide a small xml file with which you have this problem? I can save it in UTF-8 with a BOM myself.
Dimitre Novatchev
I should qualify this statement, it was an XSD File created by Microsoft's XSD Schema creator from an XML file. That's what caused it.
George Stocker
javac pukes on this too, BTW. At least in J2SE 1.5
Adam Jaskiewicz
+3  A: 

here's how you do it with vim:

# vim file.xml
:set nobomb
:wq
bene