Attributes¶
Attributes are name-value pairs on element nodes.
Reading Attributes¶
doc = XML::Parser.string('<book id="1" lang="en"/>').parse
node = doc.root
# Hash-style access
node['id'] # => "1"
node['lang'] # => "en"
# Attribute object
attr = node.attributes.get_attribute('id')
attr.name # => "id"
attr.value # => "1"