Yeah, I knew I could do it that way , it's just not clean enough for me...
 
j.

 
On 10/27/05, Dave Burt <[EMAIL PROTECTED]> 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



--
" http://ruby-lang.org -- do you ruby?"

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

Reply via email to