class Nokogiri::XML::Node

def parse string_or_io, options = nil

+string_or_io+.
*this* node. Returns a XML::NodeSet containing the nodes parsed from
Parse +string_or_io+ as a document fragment within the context of
##
def parse string_or_io, options = nil
  ##
  # When the current node is unparented and not an element node, use the
  # document as the parsing context instead. Otherwise, the in-context
  # parser cannot find an element or a document node.
  # Document Fragments are also not usable by the in-context parser.
  if !element? && !xml? && (!parent || parent.fragment?)
    return document.parse(string_or_io, options)
  end
  options ||= (document.html? ? ParseOptions::DEFAULT_HTML : ParseOptions::DEFAULT_XML)
  if Fixnum === options
    options = Nokogiri::XML::ParseOptions.new(options)
  end
  # Give the options to the user
  yield options if block_given?
  contents = string_or_io.respond_to?(:read) ?
    string_or_io.read :
    string_or_io
  return Nokogiri::XML::NodeSet.new(document) if contents.empty?
  ##
  # This is a horrible hack, but I don't care. See #313 for background.
  error_count = document.errors.length
  node_set = in_context(contents, options.to_i)
  if node_set.empty? and document.errors.length > error_count and options.recover?
    fragment = Nokogiri::HTML::DocumentFragment.parse contents
    node_set = fragment.children
  end
  node_set
end