for debug
Replaces this object with another object. Basically, calls Parent.replace_child
self
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
Deletes a child element.
Must be an Element
, String
, or Integer
. If Element
, the element is removed. If String
, the element is found (via XPath
) and removed. <em>This means that any parent can remove any descendant.<em> If Integer
, the Element
indexed by that number will be removed.
the element that was removed.
doc.delete_element "/a/b/c[@id='4']" doc.delete_element doc.elements["//k"] doc.delete_element 1
Evaluates to true
if this element has at least one child Element
doc = Document.new "<a><b/><c>Text</c></a>" doc.root.has_elements # -> true doc.elements["/a/b"].has_elements # -> false doc.elements["/a/c"].has_elements # -> false