diff --git a/lib/nokogiri/xml/searchable.rb b/lib/nokogiri/xml/searchable.rb index f1b720e4cf..75fafd77c0 100644 --- a/lib/nokogiri/xml/searchable.rb +++ b/lib/nokogiri/xml/searchable.rb @@ -261,7 +261,8 @@ def xpath_internal(node, paths, handler, ns, binds) end def xpath_impl(node, path, handler, ns, binds) - ctx = XPathContext.new(node) + ctx = get_xpath_context(node) + ctx.register_namespaces(ns) ctx.register_variables(binds) @@ -269,6 +270,10 @@ def xpath_impl(node, path, handler, ns, binds) ctx.evaluate(path, handler) end + + def get_xpath_context(node) + XPathContext.new(node) + end end end end