TXMLClinicsType = class(TXMLNodeCollection, IXMLClinicsType)
protected
{ IXMLClinicsType }
function Get_Clinic(Index: Integer): IXMLClinicType;
function Add: IXMLClinicType;
function Insert(const Index: Integer): IXMLClinicType;
public
procedure AfterConstruction; override;
end;
{ TXMLClinicType }
TXMLClinicType = class(TXMLNode, IXMLClinicType)
protected
{ IXMLClinicType }
function Get_No: WideString;
function Get_Title: WideString;
function Get_Date: WideString;
function Get_Topics: WideString;
procedure Set_No(Value: WideString);
procedure Set_Title(Value: WideString);
procedure Set_Date(Value: WideString);
procedure Set_Topics(Value: WideString);
end;
{ Global Functions }
function GetClinics(Doc: IXMLDocument): IXMLClinicsType;
function LoadClinics(const FileName: WideString): IXMLClinicsType;
function NewClinics: IXMLClinicsType;
下面的例子在XML树的末尾加入一个节点:
procedure TForm1.ButtonAddClick(Sender: TObject);
begin
with Clinics.Add do
begin
No := '2001-2-8; // 8th Clinic of the 2nd series of 2001
Title := 'Special Kylix 2 Clinic';
Date := '2001/12/21';
Topics := 'Kylix 2 New Features'
end
end;
如果没有把XMLDocument组件的AutoSave设置为真,可以用以下方法保存更动结果:
procedure TForm1.FormDestroy(Sender: TObject);
begin
XMLDocument1.SaveToFile;
end;