TXMLDocumentAddChild (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example sets the document element by adding a child element to the document.

Code

procedure Test_AddChild;
var
  LDocument: IXMLDocument;
  LNode: IXMLNode;
begin
  LDocument := TXMLDocument.Create(nil);
  LDocument.Active := True;

  { Add new child. This will become the document element.
    If the document element already exists, then an exception is raised. }
  LNode := LDocument.AddChild('Airbus');

  { Display document content. }
  Writeln(LDocument.XML.Text);
end;

Uses