agencysoft
asked on
How can I get the values displayed in an HTMLTableCell using DOM?
I'm writing an app in C++Builder and I'm trying to read the values located in cells in a table on a web page. I have the following code:
TComInterface<IHTMLDocumen t2> Doc;
Main->Browser->Document->Q ueryInterf ace(IID_IH TMLDocumen t2,(LPVOID *)&Doc);
if( Doc )
{
TComInterface<IHTMLElement Collection > Forms;
Doc->get_forms(&Forms);
if( Forms )
{
long count = 0;
Forms->get_length(&count);
for(long x = 0; x < count; ++x)
{
TVariant item = x;
TVariant index = 0;
TComInterface<IDispatch> Disp;
Forms->item(item, index, &Disp);
if( Disp )
{
TComInterface<IHTMLTable2> Table;
Disp->QueryInterface(IID_I HTMLTable2 ,(LPVOID*) &Table);
if( Table )
{
TComInterface<IHTMLElement Collection > Cells;
Table->get_cells(&Cells);
long count_cells=0;
Cells->get_length(&count_c ells);
for(long y=0;y < count_cells;y++)
{
TVariant cell_item = y;
TVariant cell_index = 0;
TComInterface<IDispatch> cell_Disp;
Cells->item(cell_item,cell _index,&ce ll_Disp);
if(cell_Disp)
{
TComInterface<IHTMLTableCe ll> Cell;
cell_Disp->QueryInterface( IID_IHTMLT ableCell,( LPVOID*)&C ell);
if(Cell)
{
WideString Value;
// What to put here to get data?
ShowMessage(Value);
}
}
}
}
}
}
}
}
Am I heading in the wrong direction? HTMLTableCell doesn't seem to provide any access to the data displayed in it/
Thanks for looking.
Mitch McInelly
TComInterface<IHTMLDocumen
Main->Browser->Document->Q
if( Doc )
{
TComInterface<IHTMLElement
Doc->get_forms(&Forms);
if( Forms )
{
long count = 0;
Forms->get_length(&count);
for(long x = 0; x < count; ++x)
{
TVariant item = x;
TVariant index = 0;
TComInterface<IDispatch> Disp;
Forms->item(item, index, &Disp);
if( Disp )
{
TComInterface<IHTMLTable2>
Disp->QueryInterface(IID_I
if( Table )
{
TComInterface<IHTMLElement
Table->get_cells(&Cells);
long count_cells=0;
Cells->get_length(&count_c
for(long y=0;y < count_cells;y++)
{
TVariant cell_item = y;
TVariant cell_index = 0;
TComInterface<IDispatch> cell_Disp;
Cells->item(cell_item,cell
if(cell_Disp)
{
TComInterface<IHTMLTableCe
cell_Disp->QueryInterface(
if(Cell)
{
WideString Value;
// What to put here to get data?
ShowMessage(Value);
}
}
}
}
}
}
}
}
Am I heading in the wrong direction? HTMLTableCell doesn't seem to provide any access to the data displayed in it/
Thanks for looking.
Mitch McInelly
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.