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.
jef (Guest)
on 2008-10-11 18: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
Andrew C. (Guest)
on 2008-10-12 07: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.