XmlWriterSettings do not affect XmlWriter created from XmlDocument

I need to use ISO Latin 1 encoding, but using the code below the default recording options for UTF8. What am I missing here?

XmlDocument xmlDoc = new XmlDocument(); 
XmlWriterSettings settings = new XmlWriterSettings();
settings.ConformanceLevel = ConformanceLevel.Auto;
settings.Encoding = System.Text.Encoding.GetEncoding(28591);
using (XmlWriter writer = XmlWriter.Create(xmlDoc.CreateNavigato().AppendChild(), settings))
{
}
+3
source share
1 answer

The problem is that the underlying thread (in this case, the object xmlDoc) uses UTF-8, which is the default encoding in .NET.

From the MSDN documentation The encoding property in XmlWriterSettings:

XmlWriter, , . XmlWriter TextWriter, Encoding TextWriter. , Unicode (UTF-16) XmlWriter, StreamWriter ( TextWriter) , UTF-8, UTF-8.

, XmlWriter , 1. , XmlDocument .

+1

Source: https://habr.com/ru/post/1732235/


All Articles