IT_Programming/LINQ
Removing Byte Order Mark (BOM) with LINQ
JJun ™
2010. 7. 25. 01:57
To remove the byte order mark while using LINQ-to-XML, we must specify the encoding to be
used with an XML writer. The following code will write the XDocument file to disk
[Sample]
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = new System.Text.UTF8Encoding(false);
using (XmlWriter writer = XmlWriter.Create("FileName.xml", settings))
{
file.Save(writer);
}