class Nokogiri::XML::Document

def collect_namespaces

The hash returned will look like this: { 'xmlns:foo' => 'bar' }





For example, given this document:
WARNING: this method will clobber duplicate names in the keys.

{ 'xmlns:foo' => 'bar', 'xmlns:hello' => 'world' }

This method will return:





For example, given this document:

return them as a hash.
Recursively get all namespaces from this node and its subtree and
##
def collect_namespaces
  ns = {}
  traverse { |j| ns.merge!(j.namespaces) }
  ns
end