Setting up formatting when using a XmlWriter is pretty easy. Declare a XmlWriterSettings variable and set the formatting options you want. The two main items are for indenting and new lines. You add the XmlWriterSettings variable as the second parameter in the XmlWriter.Create function.
VB.Net Example
Dim mySettings As New XmlWriterSettings()
mySettings.Indent = True
mySettings.NewLineOnAttributes = True
Using writer As XmlWriter = XmlWriter.Create("c:\test.xml", settings)
C# Example
XmlWriterSettings mySettings = new XmlWriterSettings();
mySettings.Indent = true;
mySettings.NewLineOnAttributes = true;
using (XmlWriter writer = XmlWriter.Create("c:\test.xml", mySettings))
Technorati Tags:
VB.Net,
CSharp