I am writing some data to XML file...but when I open it all the values are in a single line...how can write it in readable format?ie each node in new line and indentation?>
A little VB.NET version using XmlWriter plus XmlWriterSettings direct to file:
Dim oSerializer As New XmlSerializer(GetType(MyType), New XmlRootAttribute("MyRootAttributeName"))
Using oXmlWriter As XmlWriter = XmlWriter.Create("MyFilePath", New XmlWriterSettings With {.Indent = True}) //Default encoding is utf-8
oSerializer.Serialize(oXmlWriter, oInstanceOfMyType)
oXmlWriter.Flush()
End Using
Check the doco for other settings and file overwrite options but this is clean and works as expected in lots of situations.