Returns the previous sibling that is an element, or nil if there is no Element sibling prior to this one
doc = Document.new '<a><b/>text<c/></a>' doc.root.elements['c'].previous_element #-> <b/> doc.root.elements['b'].previous_element #-> nil
421 422 423 424 425
# File 'lib/rexml/element.rb', line 421 def previous_element element = previous_sibling element = element.previous_sibling until element.nil? or element.kind_of? Element return element end