I am trying to indent after a newline when using an XmlTextWriter
So essentially i want this
<?xml version="1.0" encoding="utf-16"?>
<element>
a
</element>
but using the code below i get this
<?xml version="1.0" encoding="utf-16"?>
<element>
a
</element>
Here is my current test harness
[Test]
public void XmlIndentingTest()
{
var provider = new StringBuilder();
var settings = new XmlWriterSettings
{
Indent = true,
IndentChars = " ",
};
using (var writer = new StringWriter(provider))
{
using (var xmlWriter = XmlTextWriter.Create(writer, settings))
{
xmlWriter.WriteStartElement("element");
xmlWriter.WriteString("\r\na\r\n");
xmlWriter.WriteEndElement();
}
}
Debug.WriteLine(provider.ToString());
}