xmldelphipretty-printtext-formatting

Nice bit of code to format an xml string


Anyone got a ready made function that will take an XML string and return a correctly indented string?

eg

<XML><TAG1>A</TAG1><TAG2><Tag3></Tag3></TAG2></XML>

and will return nicely formatted String in return after inserting linebreaks and tabs or spaces?


Solution

  • The RTL has FormatXMLData in XMLDoc.pas that accepts and returns strings.