I am searching a webpage table object in which neither the table nor
the elements have been named. This has forced me to search all <TD>s
on the page for a match. Once I have the match I can read any cell in
that row by using parentElement and cell number. Is there an easy way
to refer back to the parent row, row collection and table? I have
tried nested parentElement but it does not seem to work. If I could
get the parent table, and the row index of the cell I would be set.

Re: Searching webpage table object by TDM

TDM
Thu May 10 13:57:46 CDT 2007


"Brendan" <brendandetracey@yahoo.com> wrote in message
news:1178798630.409678.81550@n59g2000hsh.googlegroups.com...
>I am searching a webpage table object in which neither the table nor
> the elements have been named. This has forced me to search all <TD>s
> on the page for a match. Once I have the match I can read any cell in
> that row by using parentElement and cell number. Is there an easy way
> to refer back to the parent row, row collection and table? I have
> tried nested parentElement but it does not seem to work. If I could
> get the parent table, and the row index of the cell I would be set.
>

Maybe this will help ? This is takend from a function I wrote to look for
specific text in a table. objTags.Name should give you the
name of the Table. Hope I did not leave anything out.

strURL = "http://www.page.com"
Set objIE = WScript.CreateObject("InternetExplorer.Application")
With objIE
.Navigate(strURL)
Do
.StatusText = .ReadyState & "Loading, please wait .."
Loop While .ReadyState <> 4
.Document.Close
Set objIEDoc = .Document
End With

Set objIEDoc = objIE.Document
Set objIEDocElements = objIEDoc.All
Set objTags = objIEDocElements.tags("table")

For Each itm In objTags
For i = 0 To itm.Rows.Length - 1
If InStr(1, LCase(itm.Rows(i).InnerText), "texttolookfor", 1) <> 0 Then
WScript.Echo "Text Found"
Next
Next


TDM



Re: Searching webpage table object by Brendan

Brendan
Fri May 11 06:49:18 CDT 2007

On May 10, 3:57 pm, "TDM" <rpu...@gmail.com> wrote:
> "Brendan" <brendandetra...@yahoo.com> wrote in message
>
> news:1178798630.409678.81550@n59g2000hsh.googlegroups.com...
>
> >I am searching a webpage table object in which neither the table nor
> > the elements have been named. This has forced me to search all <TD>s
> > on the page for a match. Once I have the match I can read any cell in
> > that row by using parentElement and cell number. Is there an easy way
> > to refer back to the parent row, row collection and table? I have
> > tried nested parentElement but it does not seem to work. If I could
> > get the parent table, and the row index of the cell I would be set.
>
> Maybe this will help ? This is takend from a function I wrote to look for
> specific text in a table. objTags.Name should give you the
> name of the Table. Hope I did not leave anything out.
>
> strURL = "http://www.page.com"
> Set objIE = WScript.CreateObject("InternetExplorer.Application")
> With objIE
> .Navigate(strURL)
> Do
> .StatusText = .ReadyState & "Loading, please wait .."
> Loop While .ReadyState <> 4
> .Document.Close
> Set objIEDoc = .Document
> End With
>
> Set objIEDoc = objIE.Document
> Set objIEDocElements = objIEDoc.All
> Set objTags = objIEDocElements.tags("table")
>
> For Each itm In objTags
> For i = 0 To itm.Rows.Length - 1
> If InStr(1, LCase(itm.Rows(i).InnerText), "texttolookfor", 1) <> 0 Then
> WScript.Echo "Text Found"
> Next
> Next
>
> TDM

Thanks for your reply. So there isn't a more direct way to find the
parent row and table of a cell? Ack...