# File lib/relax/response.rb, line 23
    def initialize(xml)
      @raw = xml
      @xml = Hpricot.XML(xml.to_s)

      if parameters = self.class.instance_variable_get('@parameters')
        parameters.each do |parameter, options|
          begin
            element = options[:element] || parameter

            if attribute = options[:attribute] and attribute == true
              node = attribute(root, element)
            elsif attribute
              node = attribute(element(element), attribute)
            elsif options[:collection]
              node = elements(element)
            else
              node = element(element)
            end

            if options[:collection]
              value = node.collect do |element|
                options[:collection].new(element)
              end
            else
              case type = options[:type]
                when Response
                  value = type.new(node)

                when :date
                  value = date_value(node)

                when :time
                  value = time_value(node)

                when :float
                  value = float_value(node)

                when :integer
                  value = integer_value(node)

                when :text
                else
                  value = text_value(node)
              end
            end

            instance_variable_set("@#{parameter}", value)
          rescue Hpricot::Error
            raise MissingParameter if options[:required]
          end
        end
      end
    end