Geeks With Blogs
Bunch's Blog One day I'll have a catchy subtitle, one day

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: ,
Posted on Monday, July 18, 2011 12:22 PM | Back to top

Comments on this post: XmlWriter Formatting

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Bunch | Powered by: