Method: REXML::Element#delete_attribute
- Defined in:
- lib/rexml/element.rb
#delete_attribute(key) ⇒ Object
Removes an attribute
- key
-
either an Attribute or a String. In either case, the attribute is found by matching the attribute name to the argument, and then removed. If no attribute is found, no action is taken.
- Returns
-
the attribute removed, or nil if this Element did not contain a matching attribute
e = Element.new('E')
e.add_attribute( 'name', 'Sean' ) #-> <E name='Sean'/>
r = e.add_attribute( 'sur:name', 'Russell' ) #-> <E name='Sean' sur:name='Russell'/>
e.delete_attribute( 'name' ) #-> <E sur:name='Russell'/>
e.delete_attribute( r ) #-> <E/>
619 620 621 622 |
# File 'lib/rexml/element.rb', line 619 def delete_attribute(key) attr = @attributes.get_attribute(key) attr.remove unless attr.nil? end |