I am using the following code:

require 'net/http'
# read the page data
http = Net::HTTP.new('kvcrpf.org', 80)
resp, page = http.get('/achievements.htm', nil )
# BEGIN processing HTML
def parse_html(data,tag)
   return data.scan(%r{<#{tag}\s*.*?>(.*?)</#{tag}>}im).flatten
end
output = []
table_data = parse_html(page,"table")
table_data.each do |table|
   out_row = []
   row_data = parse_html(table,"tr")
   row_data.each do |row|
      cell_data = parse_html(row,"td")
      cell_data.each do |cell|
         cell.gsub!(%r{<.*?>},"")
      end
      out_row << cell_data
   end
   output << out_row
end
# END processing HTML
# examine the result
def parse_nested_array(array,tab = 0)
   n = 0
   array.each do |item|
      if(item.size > 0)
         puts "#{"\t" * tab}[#{n}] {"
         if(item.class == Array)
            parse_nested_array(item,tab+1)
         else
            puts "#{"\t" * (tab+1)}#{item}"
         end
         puts "#{"\t" * tab}}"
      end
      n += 1
   end
end
parse_nested_array(output[2][4])


It displays the output like this:
[0] {
 2004
}
[1] {
 65
}
[2] {
 58
}
[3] {
 89.23
}


I want to store the value 2004, 65, 58, 89.23 in variables like this:
aa = 2004
ab = 65
ac = 58
ad = 89.23

Please help me, in doing this.
Thanks in advance
Vikash

Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download 
Now! http://messenger.yahoo.com/download.php
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to