Link to home
Start Free TrialLog in
Avatar of agencysoft
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<IHTMLDocument2> Doc;
        Main->Browser->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&Doc);
        if( Doc )
        {
            TComInterface<IHTMLElementCollection> 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_IHTMLTable2,(LPVOID*)&Table);
                        if( Table )
                        {
                          TComInterface<IHTMLElementCollection> Cells;
                          Table->get_cells(&Cells);
                          long count_cells=0;
                          Cells->get_length(&count_cells);


                          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,&cell_Disp);

                            if(cell_Disp)
                            {
                             TComInterface<IHTMLTableCell> Cell;
                             cell_Disp->QueryInterface(IID_IHTMLTableCell,(LPVOID*)&Cell);

                             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
Avatar of George Tokas
George Tokas
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial