Method: REXML::Attributes#delete_all

Defined in:
lib/rexml/element.rb

#delete_all(name) ⇒ Object

:call-seq:

delete_all(name) -> array_of_removed_attributes

Removes all attributes matching the given name; returns an array of the removed attributes:

xml_string = "  <root xmlns:foo=\"http://foo\" xmlns:bar=\"http://bar\">\n     <ele foo:att='1' bar:att='2' att='&lt;'/>\n  </root>\n"
d = REXML::Document.new(xml_string)
ele = d.root.elements['//ele'] # => <a foo:att='1' bar:att='2' att='&lt;'/>
attrs = ele.attributes
attrs.delete_all('att') # => [att='&lt;']


2538
2539
2540
2541
2542
2543
2544
2545
# File 'lib/rexml/element.rb', line 2538

def delete_all( name )
  rv = []
  each_attribute { |attribute|
    rv << attribute if attribute.expanded_name == name
  }
  rv.each{ |attr| attr.remove }
  rv
end