Registriert seit: 21. Aug 2003
7.332 Beiträge
Delphi 2009 Professional
|
Re: XML: #4 (usw.) abspeichern
26. Jan 2006, 13:59
Hi marabu,
am Besten zeig ich dir mal meine ganze Routine:
Delphi-Quellcode:
procedure TProfile.Save;
procedure DoSave(Doc: IXMLDocument);
var
I: Integer;
Node: IXMLNode;
Profil: TProfil;
tmp: String;
begin
Node := Doc.DocumentElement.AddChild(' count');
SetNodeInt(Node, ' count', Count);
for I := 0 to Count - 1 do
begin
Profil := Items[I];
Node := Doc.DocumentElement.AddChild(' profile' + IntToStr(I));
SetNodeText(Node, ' user', Profil.Benutzername);
with TCipher_Rijndael.Create(PW, nil) do
begin
tmp := EncodeString(Profil.Passwort);
Free;
end;
tmp := UTF8Encode(tmp);
SetNodeText(Node, ' password', tmp);
SetNodeText(Node, ' domain', Profil.Domain);
SetNodeText(Node, ' desc', Profil.Beschreibung);
end;
end;
var
XMLDoc: IXMLDocument;
begin
if ( not (FileExists(FileName))) then
TFileStream.Create(FileName, fmCreate).Free;
XMLDoc := TXMLDocument.Create( nil);
XMLDoc.XML.Add(' <?xml version="1.0" encoding="UTF-8"?>');
XMLDoc.XML.Add(' <profile></profile>');
XMLDoc.Active := true;
DoSave(XMLDoc);
XMLDoc.SaveToFile(FileName);
end;
Ich arbeite mit MSXML^^
|
|
Zitat
|