Разобрался с циклом, но теперь не получается вывести данные в массив.
Код:
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
XMLDocument1.LoadFromFile('test.xml');
XMLDocument1.Active := true;
with XMLDocument1.DocumentElement.ChildNodes['city'] do
for i:= 0 to ChildNodes.Count-1 do
begin
StringGrid1.RowCount:= StringGrid1.RowCount+1;
StringGrid1.Cells[1,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['cityname'].Text);
StringGrid1.Cells[2,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['citytime'].Text);
StringGrid1.Cells[3,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['step'].ChildNodes['datetime'].Text);
StringGrid1.Cells[4,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['step'].ChildNodes['pressure'].Text);
StringGrid1.Cells[5,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['step'].ChildNodes['temperature'].Text);
StringGrid1.Cells[6,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['step'].ChildNodes['humidity'].Text);
StringGrid1.Cells[7,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['step'].ChildNodes['cloudcover'].Text);
StringGrid1.Cells[8,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['step'].ChildNodes['windspeed'].Text);
StringGrid1.Cells[9,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['step'].ChildNodes['windgust'].Text);
StringGrid1.Cells[10,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['step'].ChildNodes['winddir'].Text);
StringGrid1.Cells[11,StringGrid1.RowCount-1]:=VarToStr (XMLDocument1.DocumentElement.ChildNodes['city'].ChildNodes['step'].ChildNodes['precipitation'].Text);
end;
XMLDocument1.Active := false;
end;
Теперь читает весь файл, но почему-то в каждую строчку выводит данные из первого блока.
Как исправить?