Method: REXML::Attributes#each_attribute

Defined in:
lib/rexml/element.rb

#each_attributeObject

Iterates over the attributes of an Element. Yields actual Attribute nodes, not String values.

doc = Document.new '<a x="1" y="2"/>'
doc.root.attributes.each_attribute {|attr|
  p attr.expanded_name+" => "+attr.value
}


1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
# File 'lib/rexml/element.rb', line 1035

def each_attribute # :yields: attribute
  return to_enum(__method__) unless block_given?
  each_value do |val|
    if val.kind_of? Attribute
      yield val
    else
      val.each_value { |atr| yield atr }
    end
  end
end