class Nokogiri::XML::Document

def collect_namespaces

libxml bridge into a ruby object.
traverses the entire graph, and also has to bring each node across the
Note this is a very expensive operation in current implementation, as it

in the hash.
Non-prefixed default namespaces (as in "xmlns=") are not included

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