Problem with Hpricot and attributes

I am trying to run the following code:

require ‘rubygems’
require ‘hpricot’
require ‘open-uri’

doc = Hpricot(open("*the url is here"))
tables =(doc/“table”)
(tables[6]/“tr”).each do |major|
name = major.search(“td”).first.inner_html
abbrev =major.search(“acronym”).inner_html
link = major.search(“a”)
path = link.attributes[‘href’]
puts path
end

Everytime I run it, I get this error though: undefined method
`attributes’ for #Hpricot::Elements[] (NoMet
hodError)

Am I missing something?

On 1/24/07, [email protected] [email protected] wrote:

Everytime I run it, I get this error though: undefined method
`attributes’ for #Hpricot::Elements[] (NoMet
hodError)

#search always returns an array of elements, even if it only found one.

Use #at if you only want the first element.

http://code.whytheluckystiff.net/hpricot/


Chris W.