XDocument: saving XML to file without BOM

I'm generating an utf-8 XML file using XDocument.

XDocument xml_document = new XDocument(
                    new XDeclaration("1.0", "utf-8", null),
                    new XElement(ROOT_NAME,                    
                    new XAttribute("note", note)
                )
            );
...
xml_document.Save(@file_path);

The file is generated correctly and validated with an xsd file with success.

When I try to upload the XML file to an online service, the service says that my file is wrong at line 1; I have discovered that the problem is caused by the BOM on the first bytes of the file.

Do you know why the BOM is appended to the file and how can I save the file without it?

As stated in Byte order mark Wikipedia article:

While Unicode standard allows BOM in UTF-8 не требует или рекомендую . Порядок байтов не имеет значение в UTF-8, поэтому только спецификация служит для идентификации текстового потока или файл как UTF-8 или что он был преобразован из другого формата, имеющего спецификацию

. Это проблема XDocument , или мне следует связаться с парнями из поставщика онлайн-услуг, чтобы попросить обновить парсер?

38
задан systempuntoout 9 February 2011 в 16:00
поделиться