procedure TContactCollection.SaveToXMLFile;
procedure WriteFileInfo;
begin
end;
procedure WriteContact(Contact: TContact);
var
NewNode : IXMLDOMNode;
begin
if FXMLDoc.documentElement =
nil then Exit;
NewNode := FXMLDoc.createElement('
Kontakt');
if (NewNode <>
nil)
then
try
createElement(FXMLDoc, NewNode, '
Name', Contact.
Name);
createElement(FXMLDoc, NewNode, '
Vorname', Contact.Vorname);
createElement(FXMLDoc, NewNode, '
Strasse', Contact.Strasse);
createElement(FXMLDoc, NewNode, '
PLZ', Contact.PLZ);
createElement(FXMLDoc, NewNode, '
Ort', Contact.Ort);
createElement(FXMLDoc, NewNode, '
Land', Contact.Land);
createElement(FXMLDoc, NewNode, '
Telefon1', Contact.Telefon1);
createElement(FXMLDoc, NewNode, '
Telefon2', Contact.Telefon2);
createElement(FXMLDoc, NewNode, '
EMail1', Contact.EMail1);
createElement(FXMLDoc, NewNode, '
EMail2', Contact.EMail2);
createElement(FXMLDoc, NewNode, '
URL', Contact.Homepage);
createElement(FXMLDoc, NewNode, '
GebDat', Contact.GebDat);
createElement(FXMLDoc, NewNode, '
Firma', Contact.Firma);
// createElement(FXMLDoc, NewNode, 'Bem', Contact.Bem);
// neuen Knoten anhängen
FXMLDoc.documentElement.appendChild(NewNode);
finally
NewNode :=
nil;
end;
end;
var
i : Integer;
begin
FXMLDoc := CoDOMDocument40.Create;
FXMLDoc.async := false;
FXMLDoc.resolveExternals := false;
FXMLDoc.preserveWhiteSpace := false;
// wenn XML-Adressdatei nicht existiert, neu anlegen
if (
not FileExists(FFilename))
then
begin
FXMLDoc.loadXML('
<?xml version="1.0" encoding="ISO-8859-1"?><adressdb/>');
end;
//WriteFileInfo;
for i := 0
to Self.Count - 1
do
begin
WriteContact(Self.Items[i]);
end;
FXMLDoc.save(FFilename);
end;