TXMLDocumentGeneratePrefix (Object Pascal)

From Appmethod Code Examples
Jump to: navigation, search

Description

The following example uses the GeneratePrefix function and NSPrefixBase property.

Code

procedure Test_GeneratePrefix;
var
  LDocument: TXMLDocument;
  LNode: IXMLNode;
  LPrefix: DOMString;
begin
  LDocument := TXMLDocument.Create(nil);
  LDocument.Active := True;

  { If the document element doesn't exist and
    function GeneratePrefix is called, then an exception is raised. }
  LNode := LDocument.CreateNode('TestElement');
  LDocument.DocumentElement := LNode;

  LDocument.NSPrefixBase := 'PrefBase';
  LPrefix := LDocument.GeneratePrefix(LNode);
  Writeln(LPrefix);

  LDocument.Free;
end;

Uses