unit EnterpiseUnit;
interface
uses xmldom, XMLDoc, XMLIntf;
type
{ Forward Decls }
IXMLEnterpriseInfoType = interface;
IXMLRecordType = interface;
{ IXMLEnterpriseInfoType }
IXMLEnterpriseInfoType = interface(IXMLNodeCollection)
['{453A2D6F-2EB1-463A-81C1-575F1A16327F}']
{ Property Accessors }
function Get_Record_(Index: Integer): IXMLRecordType;
{ Methods &
Properties }
function Add: IXMLRecordType;
function Insert(const Index: Integer): IXMLRecordType;
property Record_[Index: Integer]: IXMLRecordType read Get_Record_;
default;
end;
{ IXMLRecordType }
IXMLRecordType = interface(IXMLNode)
['{659A02C4-5603-466C-8D6A-80ECCB8F5CA3}']
{ Property Accessors }
function Get_Name: WideString;
function Get_Address: WideString;
function Get_Phone: WideString;
procedure Set_Name(Value: WideString);
procedure Set_Address(Value: WideString);
procedure Set_Phone(Value: WideString);
{ Methods &
Properties }
property Name: WideString read Get_Name write Set_Name;
property Address: WideString read Get_Address write Set_Address;
property Phone: WideString read Get_Phone write Set_Phone;
end;
{ Forward Decls }
TXMLEnterpriseInfoType = class;
TXMLRecordType = class;
{ TXMLEnterpriseInfoType }
TXMLEnterpriseInfoType = class(TXMLNodeCollection, IXMLEnterpriseInfoType)
protected
{ IXMLEnterpriseInfoType }
function Get_Record_(Index: Integer): IXMLRecordType;
function Add: IXMLRecordType;
function Insert(const Index: Integer): IXMLRecordType;
public
procedure AfterConstruction;
override;
end;
{ TXMLRecordType }
TXMLRecordType = class(TXMLNode, IXMLRecordType)
protected
{ IXMLRecordType }
function Get_Name: WideString;
function Get_Address: WideString;
function Get_Phone: WideString;
procedure Set_Name(Value: WideString);
procedure Set_Address(Value: WideString);
procedure Set_Phone(Value: WideString);
end;
{ Global Functions }
function GetEnterpriseInfo(Doc: IXMLDocument): IXMLEnterpriseInfoType;
function LoadEnterpriseInfo(const FileName: WideString): IXMLEnterpriseInfoType;
function NewEnterpriseInfo: IXMLEnterpriseInfoType;
implementation
{ Global Functions }
function GetEnterpriseInfo(Doc: IXMLDocument): IXMLEnterpriseInfoType;
begin
Result :=do
c.GetDocBinding('EnterpriseInfo', TXMLEnterpriseInfoType) as IXMLEnterpriseInfoType;
end;
function LoadEnterpriseInfo(const FileName: WideString): IXMLEnterpriseInfoType;
begin
Result := LoadXMLDocument(FileName).GetDocBinding('EnterpriseInfo', TXMLEnterpriseInfoType) as IXMLEnterpriseInfoType;
end;
function NewEnterpriseInfo: IXMLEnterpriseInfoType;
begin
Result := NewXMLDocument.GetDocBinding('EnterpriseInfo', TXMLEnterpriseInfoType) as IXMLEnterpriseInfoType;
end;
{ TXMLEnterpriseInfoType }
procedure TXMLEnterpriseInfoType.AfterConstruction;
begin
RegisterChildNode('record', TXMLRecordType);
ItemTag := 'record';
ItemInterface := IXMLRecordType;
inherited;
end;
function TXMLEnterpriseInfoType.Get_Record_(Index: Integer): IXMLRecordType;
begin
Result := List[Index] as IXMLRecordType;
end;
function TXMLEnterpriseInfoType.Add: IXMLRecordType;
begin
Result := AddItem(-1) as IXMLRecordType;
end;
function TXMLEnterpriseInfoType.Insert(const Index: Integer): IXMLRecordType;
begin
Result := AddItem(Index) as IXMLRecordType;
end;
{ TXMLRecordType }
function TXMLRecordType.Get_Name: WideString;
begin
Result := ChildNodes['name'].Text;
end;
procedure TXMLRecordType.Set_Name(Value: WideString);
begin
ChildNodes['name'].NodeValue := Value;
end;
function TXMLRecordType.Get_Address: WideString;
begin
Result := ChildNodes['address'].Text;
end;
procedure TXMLRecordType.Set_Address(Value: WideString);
begin
ChildNodes['address'].NodeValue := Value;
end;
function TXMLRecordType.Get_Phone: WideString;
begin
Result := ChildNodes['phone'].Text;
end;
procedure TXMLRecordType.Set_Phone(Value: WideString);
begin
ChildNodes['phone'].NodeValue := Value;
end;
end.
长吗?不是很长吧.