[Lazarus] TSynMemo + TSynXMLSyn: How format a XML after load it?

Anthony Walter sysrpl at gmail.com
Wed Oct 28 15:37:28 CET 2015


uses
  Codebot.Text.Xml;

function PrettyXml(const Xml: string): string;
var
  D: IDocument;
begin
  D := DocumentCreate;
  D.Xml := Xml;
  D.Beautify;
  Result := D.Xml;
end;

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Text := PrettyXml(Memo1.Text);
end;

Result:

<?xml version="1.0" encoding="UTF-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" mlns:xsd="
http://www.w3.org/2001/XMLSchema">
<soap12:Body>
<ConsultaAndamentos>
<Result>
<Andamento>
<Pasta>int</Pasta>
<Processo>string</Processo>
</Andamento>
</Result>
</ConsultaAndamentos>
</soap12:Body>
</soap12:Envelope>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20151028/aae47d39/attachment-0003.html>


More information about the Lazarus mailing list