Get the type of an element in Hpricot
-
06-07-2019 - |
Question
I want to go through the children of an element and filter only the ones that are text or span
, something like:
element.children.select {|child|
child.class == String || child.element_type == 'span'
}
but I can't find a way to test which type a certain element is. How do I test that? I'd like to know that regardless if there's a better way of doing what I'm trying to do, but I also appreciate suggestions on that.
Solution
Found it:
element.name
#=> "span"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow