I have an XMLDocument that I have read in from file. The file is Unicode, and has the newline character \'\\n\'. When I write the XMLDocument back out, it has the newline ch
Use XmlWriter.Create() to create the writer and specify the format. This worked well:
using System;
using System.Xml;
class Program {
static void Main(string[] args) {
XmlWriterSettings settings = new XmlWriterSettings();
settings.NewLineChars = "\n";
settings.Indent = true;
XmlWriter writer = XmlWriter.Create(@"c:\temp\test.xml", settings);
XmlDocument doc = new XmlDocument();
doc.InnerXml = "value ";
doc.WriteTo(writer);
writer.Close();
}
}