class HTML::Selector

def next_element(element, name = nil)

skipping other sibling elements.
With the +name+ argument, returns the next element with that name,

Returns the next element after this one. Skips sibling text nodes.
def next_element(element, name = nil)
  if siblings = element.parent.children
    found = false
    siblings.each do |node|
      if node.equal?(element)
        found = true
      elsif found && node.tag?
        return node if (name.nil? || node.name == name)
      end
    end
  end
  nil
end