Forum: Ruby on Rails Hpricot problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
42db98edb8de28e50395c4959a12a46a?d=identicon&s=25 jef (Guest)
on 2008-10-11 16:45
(Received via mailing list)
Hi,

I would like to know how to retrieve the value of an attribute.

For example (doc/".nom/a")  will return an array of elements. I would
like to know the value of the href attribut of each element.

thanks for your help
Ace6bd5323485ce76e5469e5425b5d92?d=identicon&s=25 Andrew Chronister (archron)
on 2008-10-12 05:19
elems = doc.search("//a")
elems.each do |elem|
  p elem.get_attribute("href")
end
This topic is locked and can not be replied to.