On Apr 18, 11:11 am, Drew Raines <aarai... / gmail.com> wrote:
> lrleb... / gmail.com wrote:
> > At this point data contains html that looks like this
>
> > <table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>
> > <table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>
> > <table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>
> > <table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>
>
> > More stuff continues ......
>
> > I want capture each of these four tables individually for further
> > processing. I have tried a variety of methods but nothing seems to
> > work.
>
> Would something as simple as this work?  I'm not sure how complex
> your tables get.
>
>    #!/usr/bin/env ruby
>
>    require "hpricot"
>
>    doc = Hpricot("<table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>
>    <table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>
>    <table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>
>    <table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>")
>
>    (doc/"table").map {|t| puts t.to_html}
>
> This outputs:
>
>    "<table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>"
>    "<table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>"
>    "<table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>"
>    "<table><tr><td>Stuff</td></tr><tr><td>Stuff</td></tr></table>"
>
> Note that there's an Hpricot mailing list athttp://code.whytheluckystiff.net/hpricot/that might be a more
> appropriate forum for these questions.
>
> -Drew

Thanks,

This gets me a lot closer to what I need.
I'm having some problems with syntax. If I'm reading the docs
correctly map returns an array. So I should be able to do something
like

arrTables = (doc/"tables").map

And then access each table individually. For example

arrTables[0]

Luis