How can I remove the BOM from XmlTextWriter using C#?
问题 How do remove the BOM from an XML file that is being created? I have tried using the new UTF8Encoding(false) method, but it doesn't work. Here is the code I have: XmlDocument xmlDoc = new XmlDocument(); XmlTextWriter xmlWriter = new XmlTextWriter(filename, new UTF8Encoding(false)); xmlWriter.Formatting = Formatting.Indented; xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); xmlWriter.WriteStartElement("items"); xmlWriter.Close(); xmlDoc.Load(filename); XmlNode