    # File lib/nokogiri/xml/node.rb, line 505
          def parse string_or_io, options = nil
            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