class Nokogiri::XML::NodeSet

def first n = nil

Get the first element of the NodeSet.
##
def first n = nil
  return self[0] unless n
  list = []
  [n, length].min.times { |i| list << self[i] }
  list
end