class Nokogiri::XML::Node

def attributes


# })}
# value = "tall"
# }),
# href = "http://example.com/heights"
# prefix = "height",
# namespace = #(Namespace:0x564 {
# name = "size",
# #(Attr:0x550 {
# => {"size"=>
doc.at_css("child").attributes
EOF


xmlns:height='http://example.com/heights'>
doc = Nokogiri::XML(<<~EOF)

⚠ Note that only one of the attributes is returned in the Hash.

*Example* with an attribute name collision:

# })}
# value = "large"
# }),
# href = "http://example.com/sizes"
# prefix = "desc",
# namespace = #(Namespace:0x564 {
# name = "size",
# #(Attr:0x550 {
# => {"size"=>
doc.at_css("child").attributes
doc = Nokogiri::XML("")

*Example* with a namespace:

# "class"=>#(Attr:0x564 { name = "class", value = "big wide tall" })}
# => {"size"=>#(Attr:0x550 { name = "size", value = "large" }),
doc.at_css("child").attributes
doc = Nokogiri::XML("")

*Example* with no namespaces:

names (without the namespace), and the hash values are Nokogiri::XML::Attr.
Hash containing attributes belonging to +self+. The hash keys are String attribute
[Returns]

use #attribute_nodes.
simple name collision, not all attributes will be returned. In this case, you will need to
⚠ Because the keys do not include any namespace information for the attribute, in case of a

Fetch this node's attributes.

:call-seq: attributes() → Hash
def attributes
  attribute_nodes.each_with_object({}) do |node, hash|
    hash[node.node_name] = node
  end
end