# How to get html table value efficiently into an array

**URL:** <https://www.ruby-forum.com/t/how-to-get-html-table-value-efficiently-into-an-array/129474>\
**Category:** Ruby\
**Created:** [February 18, 2008, 10:35pm UTC](https://www.ruby-forum.com/t/how-to-get-html-table-value-efficiently-into-an-array/129474 "2008-02-18T22:35:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 18, 2008, 10:35pm UTC](https://www.ruby-forum.com/t/how-to-get-html-table-value-efficiently-into-an-array/129474/1 "2008-02-18T22:35:55Z")

</div>

hi guys,

I have a table in html and I’m using watir rudy to read values from  
that table and put into an array. Right now I’m doing like that:

```
  frame.table(:id, "SomeTable").rows.each_with_index{|r, i|

       totalcells=r.cells.length
       j=1
       while j<=totalcells do
         $arrayResult.push(r.cell(:index,j).text)
         j=j+1
       end
  }

```

But it’s really slow. Is there any better way to do the cell loop and  
is there any better way to save the cell values to an array instead of  
push? Thanks a lot.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 18, 2008, 11:06pm UTC](https://www.ruby-forum.com/t/how-to-get-html-table-value-efficiently-into-an-array/129474/2 "2008-02-18T23:06:04Z")

</div>

Just found out all I need to do is

$arrayResult=frame.table(:id, “SomeTable”).to\_a.flatten
