How does Hpricot ... inner_text work?

P

Phlip

Rubies:

require 'hpricot'
hdoc = Hpricot('<yo><i>nope</i><i class="foo">b xml</i></yo>')
# nope p hdoc.inner_text
# nope p hdoc.root.inner_text
# nope p hdoc.children.first.inner_text
p hdoc.get_elements_by_tag_name # <Hpricot::Elements[
p hdoc.get_elements_by_tag_name.size # 3
p hdoc.get_elements_by_tag_name.inner_text # NoMethodError

The documentation for inner_text implies it occupies the Hpricot::Elements
array.

This experiment uses get_elements_by_tag_name to fetch all descendent
elements. Then the inner_text method vanishes.

How do we get a traversal of all derived nodes' text? Working code samples
preferred! (I have tried many more variations than those...)

I'm using libhpricot-ruby1.8 with Ubuntu...
 

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,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top