procedure TfrmHtmTest.Button3Click(Sender: TObject);
var
Table : IHTMLTable;
begin
Table := fn_HtmlFindTable((web.Document as IHTMLDocument2), edit1.Text);
if Table <> nil then
begin
// sanırım işlemleri burada yapıcam fakat her satırı dönüp veriyi nasıl değiştirmem lazım
end;
end;
function TfrmHtmTest.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;
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
Uses MSHTML,
procedure TForm1.Button1Click(Sender: TObject);
var
iDoc: IHtmlDocument2;
iDisp: IDispatch;
Ov: OleVariant;
iColl: IHTMLElementCollection;
iEle: IHTMLElement;
ia: integer;
begin
WebBrowser1.ControlInterface.Document.QueryInterface(IHtmlDocument2, iDoc);
ov := 'TABLE';
iDisp := iDoc.all.tags(ov);
if Assigned(IDisp) then
begin
IDisp.QueryInterface(ihtmlelementcollection, iColl);
if Assigned(iColl) then
begin
for ia := 1 to iColl.Get_length do
begin
iDisp := iColl.item(pred(ia), 0);
iDisp.QueryInterface(iHTMLelement, iEle);
if iEle.tagName = 'TABLE' Then // Burada Diğer kriterleri kontrol edebilirsin ..
if Application.MessageBox(PChar(iEle.outerHTML),'Bilgi Değişikliği Yapılsınmı ?',MB_YESNO)=mrYes then
iEle.outerHTML := '<div>dfdfdf</div>';
end;
end;
end;
end;
Burada dikkat etmen gereken tek şey değişiklik yaptığında (iColl.Get_Length) element sayısı değişebileceği için değişiklikden sonra hatalar olabilir ..
Kim ilim öğrenir sonra da onu gizlerse âhirette onun ağzına ateşten bir gem vurulur. (Hadis-i Şerif)