On 21. Mar 2024, at 16:11, Lee Badham via MBS Xojo Plugins wrote:
Hi,
Are there any examples of using XMLConfigurationMBS.formatprettyprint?
Thanks for asking.
Here is a sample:
// parse it
Dim doc As New XMLDocumentMBS("<f>1</f><f>2</f><f>3</f><f>4</f></test>")
// create serializer
Dim serializer As New XMLSerializerMBS
// options
Dim config As XMLConfigurationMBS = serializer.DOMConfig
serializer.NewLine = EndOfLine
config.SpaceFirstLevelElements = False
config.FormatPrettyPrint = True
// and output to string
Dim s1 As String = serializer.writeToString(doc)
// options
config.FormatPrettyPrint = False
// and output to string
Dim s2 As String = serializer.writeToString(doc)
Break // compare in debugger
It will do the nice formatted one and the compact one.
If you set FormatPrettyPrint to true, you may set SpaceFirstLevelElements to false to avoid empty lines.
Best regards,
Christian
--
Read our blog about news on our plugins:
http://www.mbsplugins.de/