method
match
match(element, path, namespaces=EMPTY_HASH)
public
Hide source
# File lib/rexml/quickpath.rb, line 23 def QuickPath::match element, path, namespaces=EMPTY_HASH raise "nil is not a valid xpath" unless path results = nil Functions::namespace_context = namespaces case path when /^\/([^\/]|$)/ # match on root path = path[1..-1] return [element.root.parent] if path == '' results = filter([element.root], path) when /^[-\w]*::/ results = filter([element], path) when /^\*/ results = filter(element.to_a, path) when /^[\[!\w:]/ # match on child children = element.to_a results = filter(children, path) else results = filter([element], path) end return results end