1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, xmldom, XMLIntf, StdCtrls, msxmldom, XMLDoc, ExtCtrls, FileCtrl,
Grids, Outline, ComCtrls, ShellCtrls, ImgList;
type
TMainForm = class(TForm)
XMLDoc: TXMLDocument;
Button1: TButton;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
procedure TMainForm.Button1Click(Sender: TObject);
var
XmlNode: IXMLNode;
begin
if not savedialog1.Execute then Exit;
XMLdoc.ChildNodes.Clear;
XMLdoc.Version := '1.0';
XMLdoc.Encoding := 'ISO-8859-1';
XmlNode := XMLdoc.DocumentElement; //pour accéder au noeud racine du document XML
XmlNode.AddChild('Noeoud1')
with XMLdoc.AddChild('Savegarde') do
begin
with AddChild('Personne') do
begin
AddChild('Nom').Text := 'Bob';
AddChild('taille').Text := '1m87';
AddChild('YeseColor').Text := 'blue';
end;
with AddChild('Personne') do
begin
with AddChild('Nom').Text :='Stive';
AddChild('taille').Text :='1m57';
AddChild('YeseColor').Text :='vert';
end;
end;
XMLdoc.SaveToFile(Savedialog1.filename);
end; |
Partager