Цитата:
Сообщение от LIONSMILE
...Помогите пожалуйста с обработчиком Button2...
|
Вот предварительный вариант, пока наполнение через сетки идёт, будет-ли работать?
Код:
procedure TForm1.Button2Click(Sender: TObject);
var
s: string;
i,j,b: integer;
begin
for b := 0 to StringGrid1.RowCount-1 do
begin
XMLDocument1.LoadFromFile('https://geocode-maps.yandex.ru/1.x/?geocode=' +
StringGrid1.Cells[0, b]);
Application.ProcessMessages;
XMLDocument1.Active:= true;
s:= VarToStr(XMLDocument1.DocumentElement.ChildNodes.Nodes['GeoObjectCollection'].XML);
Application.ProcessMessages;
j:= Pos('<pos>', s)+5;
i:= Pos('</pos>',s);
s:= Copy(s, j, i-j);
j:= Pos(' ', s);
with StringGrid2 do
begin
RowCount:= b;
Rows[b][0]:= StringGrid1.Cells[0,b];
Rows[b][1]:= Copy(s,1,j-1);
Rows[b][2]:= Copy(s,j+1,(Length(s)-j)+1);
end;
XMLDocument1.Active:= false;
end; {for}
end;
Сам к сожалению, не проверю - корпоративный файрвол с яндексом не дружит :-(