hpricot search help

J

Junkone

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

<TABLE cellSpacing=1 width="80%" align=center border=0><!--
startingtable -->

how can i do using search functionality in hpricot.

appreciate any help
 
T

Todd Benson

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

<TABLE cellSpacing=1 width="80%" align=center border=0><!--
startingtable -->

how can i do using search functionality in hpricot.

appreciate any help

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 = <TABLE cellspacing=1 width= 80% align=center border=0><!--
startingtable -->
doc = Hpricot(str)
p doc.search("table").inner_html

=>"<!-- startingtable -->\n"

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

Todd
 
D

daniel hoey

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 = <TABLE cellspacing=1 width= 80% align=center border=0><!--
startingtable -->
doc = Hpricot(str)
p doc.search("table").inner_html

=>"<!-- startingtable -->\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(' said:
table = (h/'table > comment()')[0].parent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top