TXMLDocumentNodeIndentStr (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example uses the NodeIndentStr property.

Code

procedure Test_NodeIndentStr;
const
  CIndentation = '      ';
var
  LDocument: IXMLDocument;
  LNode: IXMLNode;
begin
  LDocument := TXMLDocument.Create(nil);
  LDocument.Active := True;

  LDocument.NodeIndentStr := CIndentation;
  LDocument.Options := LDocument.Options + [doNodeAutoIndent];
  { Uncomment the following line to see the formatting difference. }
  //LDocument.Options := LDocument.Options - [doNodeAutoIndent];

  { Create some nodes. }
  LDocument.DocumentElement := LDocument.CreateNode('GMC', ntElement);
  LNode := LDocument.DocumentElement.AddChild('SUV');
  LNode.Text := 'Typhoon';

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

Uses