class Nokogiri::XML::Node

def fragment?

Returns true if this is a DocumentFragment
def fragment?
  type == DOCUMENT_FRAG_NODE
end