Dave,

A problem that both variaions will have is with nested tables. This is 
because if table B is in table A, the rows in table B will also be listed 
as belonging to table A. I don't think this is your intention.

Bret

At 07:31 PM 10/27/2005, Dave Burt wrote:
>Jeff Wood wrote:
> > I'm not seeing an easy way to iterate over the rows &| cells in tables ...
> >
> > I'm going to look into this and see what I can provide.
> >
> > Anybody else have any information or suggestions?
>
>I'm not against this being doable in Ruby, but there is the COM
>interface to the DOM:
>
>ie.document.getElementsByTagName("table").each do |table|
>   table.getElementsByTagName("tr").each do |tr|
>     tr.getElementsByTagName("th").each do |th|
>       puts th.innerText
>     end
>     tr.getElementsByTagName("td").each do |td|
>       puts td.innerText
>     end
>   end
>end
>
>Or you can easily get a collection of Watir::Table objects and use those:
>
>tables = []
>ie.document.getElementsByTagName("table").each do |table|
>   tables << Watir::Table.new(ie, :from_object, table)
>end
>
>tables[4].each{|tr| tr.each {|td| print td.text + "|" }; puts }
>#=> "Operator|Ext|City|
>Starflower|8172|San Francisco|
>Melody|5673|San Pedro|
>Symphony|3820|Montreal|"
>
>Cheers,
>Dave
>
>_______________________________________________
>Wtr-general mailing list
>[email protected]
>http://rubyforge.org/mailman/listinfo/wtr-general

_____________________
  Bret Pettichord
  www.pettichord.com

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to