LoadFromXML AdvStringGrid Parsing Error

Hello!

I would like to import a previously saved XML file into a AdvStringGrid.
Export works, but when I try to load the file, the followng error raises:
XMLDOM parsing error -1072896764 on line 4.

image

This is the code (and just two Buttons and one AdvStringGrid on the form):

procedure TForm2.Button1Click(Sender: TObject);
var
sl: TStringList;
i: integer;
begin
AdvStringGrid1.Cells[1,1]:='Cell';
AdvStringGrid1.Cells[1,0]:='Header';
sl := TStringList.Create;
for i := 0 to AdvStringGrid1.ColCount-1 do
sl.Add(AdvStringGrid1.Cells[I,0]);
AdvStringGrid1.SaveToXML('C:\temp\test.xml', 'xmllist', 'xmlrecord', sl, true);
sl.Free;
end;

procedure TForm2.Button2Click(Sender: TObject);
begin
AdvStringGrid1.Clear;
AdvStringGrid1.LoadFromXML('C:\temp\test.xml'); //<- also with both addional parameters in all combinations the error raises.
end;

Any suggestions?

Thanks in advance and best regards
Andreas

The grid header row is used to set the XML node names.
When you leave this empty, this produces invalid HTML.

You can see this when changing your code to set at least a value for the header row cells:

var
sl: TStringList;
i: integer;
begin
AdvStringGrid1.Cells[1,1]:='Cell';
AdvStringGrid1.Cells[1,0]:='Header';
sl := TStringList.Create;

for i := 0 to AdvStringGrid1.ColCount-1 do
advstringgrid1.Cells[i,0] := chr(65+i);

for i := 0 to AdvStringGrid1.ColCount-1 do
sl.Add(AdvStringGrid1.Cells[I,0]);
AdvStringGrid1.SaveToXML('E:\TMS\test.xml', 'xmllist', 'xmlrecord', sl, true);
sl.Free;
end;

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.