Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
How does Hpricot ... inner_text work?
Phlip
8/4/2007 2:56:00 AM
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...
--
Phlip
http://www.oreilly.com/catalog/9780...
"Test Driven Ajax (on Rails)"
assert_xpath, assert_javascript, & assert_ajax
1 Answer
Phlip
8/4/2007 3:34:00 PM
0
> I'm using libhpricot-ruby1.8 with Ubuntu...
When in doubt, blame Debian's clumsy Ruby packaging. The out-of-the box
Hpricot was 4.1 (with notorious bugs in the search, etc.).
Upgrading to this one provides the native inner_text:
http://archive.ubuntu.com/ubuntu/pool/universe/libh/libhpricot-ruby/libhpricot-ruby1.8_0.5-...
--
Phlip
http://www.oreilly.com/catalog/9780...
"Test Driven Ajax (on Rails)"
assert_xpath, assert_javascript, & assert_ajax
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
How does Hpricot ... inner_text work?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password