Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Creating a New Child Node
See more XML Examples
Demonstrates how to create a new child in an XML document.The following XML sample code produces this output:
<abc>
<xyz>
<mmm>123</mmm>
</xyz>
</abc>
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;
childNode: TXml;
begin
xml := TXml.Create;
xml.Tag := 'abc';
// Create a new child with no content
// and return the newly created child node:
childNode := xml.NewChild('xyz','');
// Create a child under childNode, but instead call
// NewChild2 which doesn't return the newly created child node:
childNode.NewChild2('mmm','123');
childNode.Free;
WriteLn(xml.GetXml());
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.