Method: REXML::Element#delete_attribute

Defined in:
lib/rexml/element.rb

#delete_attribute(key) ⇒ Object

:call-seq:

delete_attribute(name) -> removed_attribute or nil

Removes a named attribute if it exists; returns the removed attribute if found, otherwise nil:

e = REXML::Element.new('foo')
e.add_attribute('bar', 'baz')
e.delete_attribute('bar') # => <bar/>
e.delete_attribute('bar') # => nil


1386
1387
1388
1389
# File 'lib/rexml/element.rb', line 1386

def delete_attribute(key)
  attr = @attributes.get_attribute(key)
  attr.remove unless attr.nil?
end