Bunch's Blog

One day I'll have a catchy subtitle, one day
posts - 87 , comments - 123 , trackbacks - 0

Monday, July 18, 2011

XmlWriter Formatting

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 | Comments (0) |

Powered by: