Aşağıdaki kodda webbrowser üzerinden ismi verilen tablodaki tüm satır ve sütün içeriklerini almaya çalışıyorum
fakat biryerlerde hata yaptım bir türlü çıkamadım işin içinden
Yardımcı olabilecek arkadaşlara şimdiden teşekkürler
Kod: Tümünü seç
var
Table : IHTMLTable;
ovRow, ovCell : OleVariant;
Rows : IHTMLElementCollection;
Cells : IHTMLElementCollection;
Row : IHTMLTableRow;
Cell : IHTMLTableCell;
TextField: IHTMLTextAreaElement;
All : IHTMLElementCollection;
I, T, R, C : integer;
VNil : OleVariant;
Elements: IHTMLElement;
function fn_HtmlFindTable(_hDoc : IHtmlDocument2; _hIdName : String): IHTMLTable;
var
hAllCollectin: IHTMLElementCollection;
I,
Len: Integer;
E: OleVariant;
iE : IHTMLElement;
hTable : IHTMLTable;
begin
Result := nil;
hTable := nil;
hAllCollectin := _hDoc.All;
if hAllCollectin = Nil then Exit;
Len := hAllCollectin.Length;
for I := 0 to Len - 1 do
begin
E := hAllCollectin.Item(I, varEmpty);
iE := IDispatch(E) as IHTMLElement;
if iE.tagName <> 'TABLE' then continue;
if iE.id <> _hIdName then Continue;
hTable := (iE as IHTMLTable);
break;
end;
Result := hTable;
end;
begin
Table := fn_HtmlFindTable((WB.Document as IHTMLDocument2), 'MainContent_Info');
if Table <> nil then
begin
Rows := (Table.Rows as IHTMLElementCollection);
for R := 0 to Rows.Length - 1 do
begin
Row := Rows.Item(ovRow, R ) as IHTMLTableRow;
Cells := Row.Cells;
for C := 0 to Row.Cells.length - 1 do
begin
Cell := Cells.Item(ovCell, C ) as IHTMLTableCell;
Memo1.lines.add( ( Cell as IHTMLElement).outerText );
end;
end;
end;
end