[RESOLVED] XMLDocument.Save... Unindented :(
Hi people, does anybody know if XMLDocument.Save method can save a XML file without any formatting (unindented and without CRLFs)?
The reason for that is that XML files I work with are about 300Mb in size and indentation eats quite a lot of disk memory.
Re: XMLDocument.Save... Unindented :(
XmlDocument.Save doesn't have an option to omit the formatting. If you use XmlDocument.WriteTo you can use an XmlTextWriter which has a Formatting.None option.
Code:
Private Sub WriteXml(ByVal xDoc As XmlDocument)
Dim writer As New XmlTextWriter("C:\Temp\unindented.xml", System.Text.Encoding.UTF8)
writer.Formatting = Formatting.None
xDoc.WriteTo(writer)
writer.Flush()
writer.Close()
End Sub
Re: XMLDocument.Save... Unindented :(
Re: XMLDocument.Save... Unindented :(
Hmmm, not sure how I missed the Save overload that takes an XmlWriter. Thanks for the correction .paul.
Re: XMLDocument.Save... Unindented :(
it wasn't a correction:D you just snicked your answer in before mine
Re: [RESOLVED] XMLDocument.Save... Unindented :(
Anyway, both methods work fine. Thanks