TXMLDocumentRegisterDocBinding (Delphi)
Description
The following example uses the RegisterDocBinding function.
Code
type
TSpecXMLNode = class(TXMLNode)
public
procedure AfterConstruction; override;
function GetField: string;
end;
procedure TSpecXMLNode.AfterConstruction;
begin
Writeln(TSpecXMLNode.ClassName + ' AfterConstruction.');
end;
function TSpecXMLNode.GetField: string;
begin
Result := 'FieldValue';
end;
procedure Test_RegisterDocBinding;
const
LTag = 'TestElement';
var
LDocument: IXMLDocument;
LNode: IXMLNode;
begin
LDocument := TXMLDocument.Create(nil);
LDocument.Active := True;
{ Create document element. }
LNode := LDocument.CreateElement(LTag, EmptyStr);
LDocument.DocumentElement := LNode;
{ Register implementation class.
Should display 'TSpecXMLNode AfterConstruction'. }
LDocument.RegisterDocBinding(LTag, TSpecXMLNode);
{ Should display 'FieldValue'. }
Writeln((LDocument.DocumentElement as TSpecXMLNode).GetField);
end;
Uses
- Xml.XMLDoc.TXMLDocument.Active ( fr | de | ja )
- Xml.XMLDoc.TXMLDocument.CreateElement ( fr | de | ja )