I use XmlWriter and XmlWriterSettings to write an XML file to disk. However, a system that parses an XML file complains about encoding.
<?xml version="1.0" encoding="utf-8"?>
He wants:
<?xml version="1.0" ?>
If I try OmitXmlDeclaration = true, then I don't get the xml string at all.
string destinationName = "C:\\temp\\file.xml";
string strClassification = "None";
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create(destinationName, settings))
{
writer.WriteStartDocument();
writer.WriteStartElement("ChunkData");
writer.WriteElementString("Classification", strClassification);
writer.WriteEndElement();
}
source
share