add_element(element, attrs=nil) public

Adds a child to this element, optionally setting attributes in the element.


optional. If Element, the element is added. Otherwise, a new Element is constructed with the argument (see Element.initialize).


If supplied, must be a Hash containing String name,value pairs, which will be used to set the attributes of the new Element.


the Element that was added

el = doc.add_element 'my-tag'
el = doc.add_element 'my-tag', {'attr1'=>'val1', 'attr2'=>'val2'}
el = Element.new 'my-tag'
doc.add_element el
Show source
Register or log in to add new notes.