From: "lrlebron@..." Date: 2007-04-19T03:55:07+09:00 Subject: Re: Hpricot getting a table On Apr 18, 11:11 am, Drew Raines wrote: > lrleb...@gmail.com wrote: > > At this point data contains html that looks like this > > >
Stuff
Stuff
> >
Stuff
Stuff
> >
Stuff
Stuff
> >
Stuff
Stuff
> > > 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("
Stuff
Stuff
>
Stuff
Stuff
>
Stuff
Stuff
>
Stuff
Stuff
") > > (doc/"table").map {|t| puts t.to_html} > > This outputs: > > "
Stuff
Stuff
" > "
Stuff
Stuff
" > "
Stuff
Stuff
" > "
Stuff
Stuff
" > > 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