# File lib/multi_xml.rb, line 133
    def parse(xml, options = {}) # rubocop:disable AbcSize, CyclomaticComplexity, MethodLength, PerceivedComplexity
      xml ||= ''

      options = DEFAULT_OPTIONS.merge(options)

      xml = xml.strip if xml.respond_to?(:strip)
      begin
        xml = StringIO.new(xml) unless xml.respond_to?(:read)

        char = xml.getc
        return {} if char.nil?
        xml.ungetc(char)

        hash = undasherize_keys(parser.parse(xml) || {})
        hash = options[:typecast_xml_value] ? typecast_xml_value(hash, options[:disallowed_types]) : hash
      rescue DisallowedTypeError
        raise
      rescue parser.parse_error => error
        raise(ParseError, error.message, error.backtrace) # rubocop:disable RaiseArgs
      end
      hash = symbolize_keys(hash) if options[:symbolize_keys]
      hash
    end