Anyone got a ready made function that will take an XML string and return a correctly indented string?
eg
A
Using OmniXML:
program TestIndentXML;
{$APPTYPE CONSOLE}
uses
SysUtils,
OmniXML,
OmniXMLUtils;
function IndentXML(const xml: string): string;
var
xmlDoc: IXMLDocument;
begin
Result := '';
xmlDoc := CreateXMLDoc;
if not XMLLoadFromAnsiString(xmlDoc, xml) then
Exit;
Result := XMLSaveToAnsiString(xmlDoc, ofIndent);
end;
begin
Writeln(IndentXML('A '));
Readln;
end.
The code fragment above is released to public domain.