def get_namespaces
      @nshash.clear
      root_element = @doc.root
      root_element.attributes.each_attribute do |attr|
        if @namespace_urn.has_key?( attr.value ) then
          @nshash[@namespace_urn[attr.value]] = attr.name
          self.class.send(:attr_accessor, @namespace_urn[attr.value] + "_ns")
          send("#{@namespace_urn[attr.value]+'_ns'}=", attr.name)
        end
      end
    end
def get_namespaces
      @nshash.clear
      root_element = @doc.root
      root_element.attributes.each_attribute do |attr|
        if @namespace_urn.has_key?( attr.value ) then
          @nshash[@namespace_urn[attr.value]] = attr.name
          self.class.send(:attr_accessor, @namespace_urn[attr.value] + "_ns")
          send("#{@namespace_urn[attr.value]+'_ns'}=", attr.name)
        end
      end
    end
Establish a mapping between "standard" namespaces (in @namespace_urn)
 and namespace prefixes used in the document at hand.

 This code dynamically creates instance variables for the namespaces
 with "_ns" added to the variable name to avoid collisions.
 It is also added to the namespace hash <tt>@nshash</tt>

 The technique comes from a post to comp.lang.ruby by Guy Decoux