From: Peter Szinek Date: 2006-11-27T20:51:48+09:00 Subject: Re: How to get data from html table > I want to store the values in variables so that I can compare records. > Please help me out how to do this in ruby. One possible way: Record = Struct.new("Record", :name, :date, :name_again, :some_num, :buy_link, :some_num2, :letters, :price) records = [] doc = Hpricot(doc) stuff = doc/"/table/tr/td" elements = stuff.map { |elem| elem.inner_html }.each_slice(8) do |slice| records << Record.new(*slice) end p records.sort_by {|record| record.price.slice(1..record.size) } Note that since I did not know the semantics of the table cells, sometimes the Struct Record has some weird fields in it, but you get the idea. Also I am not 100% sure if the sort_by should not be done on to_f-d prices (probably not due to rounding problems, but I wonder if there can be some weird string issues, too). HTH, Peter __ http://www.rubyrailways.com