html table okuma hakkında yardım

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
adelphiforumz
Üye
Mesajlar: 602
Kayıt: 01 Nis 2008 05:38
Konum: İstanbul

html table okuma hakkında yardım

Mesaj gönderen adelphiforumz »

Selamlar
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
Ehil olmayanlara sabretmek ehil olanları parlatır.
Akıllı birisinden gelen cefa, bilgisizlerin vefasından iyidir.
Bilgiye ulaştı mı ayak, kanat olur
Biz insanı kıyafetiyle ağırlar bilgisiyle uğurlarız.
Mevlana
Cevapla