class Nokogiri::XML::NodeSet

def search *paths

Nokogiri::XML::Node#xpath
For more information see Nokogiri::XML::Node#css and

Search this document for +paths+
##
def search *paths
  ns = paths.last.is_a?(Hash) ? paths.pop : document.root.namespaces
  sub_set = NodeSet.new(document)
  document.decorate(sub_set)
  each do |node|
    node.search(*(paths + [ns])).each do |sub_node|
      sub_set << sub_node
    end
  end
  sub_set
end