Hpricot search help

hello
I am trying to grab the table that has a html comment in it. for eg

how can i do using search functionality in hpricot.

appreciate any help

On Sun, Mar 16, 2008 at 12:30 PM, Junkone [email protected] wrote:

There’s probably a better way, but without looking at the docs I would
probably find my table and then maybe #inner_html followed with a
regexp.

For example…

require “hpricot”
str =


doc = Hpricot(str)
p doc.search(“table”).inner_html

=>"\n"

It’s interesting to note that hpricot picked it out even though that
string is really malformed html.

Todd

On Mar 17, 10:03 am, Todd B. [email protected] wrote:

p doc.search(“table”).inner_html

=>"\n"

It’s interesting to note that hpricot picked it out even though that
string is really malformed html.

Todd

I think that this will do it:

h = Hpricot(’

<!-- some div –
')

table = (h/‘table > comment()’)[0].parent

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs