From the documentation it seems that I should be able to call find_all() on the Tag returned by a find() on a RubyfulSoup instance:
tag = doc.find('table', :attrs => {'cellspacing' => '4'})
tag.find_all('a') do |a|
if (a.is_a? Tag)
puts(a.name)
else
puts('not a Tag')
end
By my understanding the above should iterate over all the 'a' tags in the table element, but it does not. Instead the 'a' parameter in the iterator receives every node in tag. In fact, I get the same results no matter how I call tag.find_all(). I can give any parameter (or even no parameter) and the results are the same.
Am I misunderstanding the documentation? What is the best way to achieve my goal?
Thanks for any assistance.
|