I'm navigating a document using CSS selectors with Ruby, but I've found some css-selector bugs in Hpricot that are fixed in Nokogiri, and want to switch over.
The one issue I'm having is figuring out how to get an array of all children that are "containers" (i.e. not text nodes). Hpricot provides this functionality right out of the box with the containers method.
So in Hpricot I could do:
children = doc.select('*')[0].containers
But with Nokogiri, it seems the same functionality can only be had by the following (and I'm not sure if it works exactly the same way):
children = doc.css('*')[0].children.to_a.keep_if {|x| x.type != Nokogiri::XML::Node::TEXT_NODE }
Is there a better way to do this?