TXMLDocumentGetDocBinding (Delphi)
Description
The following example uses the GetDocBinding 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_GetDocBinding;
const
LTag = 'TestElement';
var
LDocument: IXMLDocument;
LNode: IXMLNode;
begin
LDocument := TXMLDocument.Create(nil);
LDocument.Active := True;
{ Register implementation class.
Should create the document element.
Should display 'TSpecXMLNode AfterConstruction'. }
LNode := LDocument.GetDocBinding(LTag, TSpecXMLNode);
{ Should display 'TestElement'. }
Writeln(LNode.LocalName);
{ Should display 'FieldValue'. }
Writeln((LNode as TSpecXMLNode).GetField);
end;
Uses
- Xml.XMLDoc.TXMLDocument.Active ( fr | de | ja )
- Xml.XMLDoc.TXMLDocument.GetDocBinding ( fr | de | ja )
- Xml.XMLIntf.IXMLNode.LocalName ( fr | de | ja )