Ho un problema che mi angoscia: devo esportare dei dati da una tabella di un database in un file XML. Funziona tutto alla grande, tranne per il fatto che le informazioni vengono scritte sul file tutte su di un rigo.
Non capisco come mai. Ecco l'evento del click del mio bottone.
grazie a chiunque voglia aiutarmi
raf
procedure TForm1.BT_creaXMLClick(Sender: TObject);
var
str: TFileStream;
s: string;
i: Integer;
begin
str := TFileStream.Create ('ditte.xml', fmCreate);
try
SimpleDataSet2.First;
s := '<?xml version="1.0" standalone="yes" ?><employee>' ;
str.Write(s[1], Length (s));
while not SimpleDataSet2.EOF do
begin
s := '';
for i := 0 to SimpleDataSet2.FieldCount - 1 do
s := s + MakeXmlstr (SimpleDataSet2.Fields[i].FieldName,
SimpleDataSet2.Fields[i].AsString);
s := MakeXmlStr ('employeeData', s);
str.Write(s[1], length (s));
SimpleDataSet2.Next
end;
s := '</employee>' ;
str.Write(s[1], length (s));
finally
str.free;
end;
end;