Method: REXML::Attributes#each
- Defined in:
- lib/rexml/element.rb
#each ⇒ Object
:call-seq:
each {|expanded_name, value| ... }
Calls the given block with each expanded-name/value pair:
xml_string = <<-EOT
<root xmlns:foo="http://foo" xmlns:bar="http://bar">
<ele foo:att='1' bar:att='2' att='<'/>
</root>
EOT
d = REXML::Document.new(xml_string)
ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='<'/>
ele.attributes.each do |, value|
p [, value]
end
Output:
["foo:att", "1"]
["bar:att", "2"]
["att", "<"]
2276 2277 2278 2279 2280 2281 |
# File 'lib/rexml/element.rb', line 2276 def each return to_enum(__method__) unless block_given? each_attribute do |attr| yield [attr., attr.value] end end |