Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
XML EmitCompact
See more XML Examples
Demonstrates the XML EmitCompact property to generate XML that is not pretty-printed, but is instead compact with whitespace removed.Note: This example requires Chilkat v9.5.0.64 or later.
Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Xml;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
xml: TXml;
begin
// Note: This example requires Chilkat v9.5.0.64 or later.
xml := TXml.Create;
xml.Tag := 'aaa';
xml.NewChild2('red|green|blue','sky');
// Show the XML in normal indented (pretty-printed) format:
WriteLn(xml.GetXml());
// The output:
// <?xml version="1.0" encoding="utf-8" ?>
// <aaa>
// <red>
// <green>
// <blue>sky</blue>
// </green>
// </red>
// </aaa>
// Now set the EmitCompact property.
xml.EmitCompact := True;
// Show the XML in compact form:
WriteLn(xml.GetXml());
// The compact output:
// <?xml version="1.0" encoding="utf-8" ?>
// <aaa><red><green><blue>sky</blue></green></red></aaa>
//
xml.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.