Byte Order Mark (BOM) 

I want to store xml in a SQL column type TEXT. I able to output the file properly as .xml file. But when I insert into database, I notice there is ‘special’ characters in front my xml.

After quick searching, found out it is actually a representation of Byte Order Mark(BOM) by encoding utf-8. More details in the Wiki

So, let’s jump into workaround to avoid the BOM  appearing.

Dim stream As New System.IO.MemoryStream
Dim uft8 As New System.Text.UTF8Encoding(False)
Dim xmlWriter As New XmlTextWriter(stream, uft8)

In the UTF8Encoding Constructor, just set the encoderShouldEmitUTF8Identifier boolean to false. Done.