class Nokogiri::XML::Reader

def attributes

[Returns] (Hash) Attribute names and values

Get the attributes of the current node as a Hash
def attributes
  attrs_hash = attribute_nodes.each_with_object({}) do |node, hash|
    hash[node.name] = node.to_s
  end
  ns = namespaces
  attrs_hash.merge!(ns) if ns
  attrs_hash
end