class REXML::Element
def add_element element, attrs=nil
e0[1] # =>
e0.add_element(e1, {'bat' => '0', 'bam' => '1'})
sets attributes on the added element:
With argument +element+ and hash argument +attributes+,
e0[0] # =>
e0.add_element(e1)
e1 = REXML::Element.new('bar')
e0 = REXML::Element.new('foo')
With element argument +element+, adds that element as a child:
e0[1] # =>
e0.add_element('baz', {'bat' => '0', 'bam' => '1'})
sets attributes on the new element:
With argument +name+ and hash argument +attributes+,
e0[0] # =>
e0.add_element('bar')
e0 = REXML::Element.new('foo')
and adds the new element as a child:
With string argument +name+, creates a new element with that name
on the added element; returns the added element.
Adds a child element, optionally setting attributes
add_element(element, attributes = nil) -> element
add_element(name, attributes = nil) -> new_element
:call-seq:
def add_element element, attrs=nil raise "First argument must be either an element name, or an Element object" if element.nil? el = @elements.add(element) attrs.each do |key, value| el.attributes[key]=value end if attrs.kind_of? Hash el end