# File lib/deltacloud.rb, line 131
    def xml_to_class(base_object, item)
      
      return nil unless item

      params = {
          :id => item['id'],
          :url => item['href'],
          :name => item.name,
          :client => self
      }
      params.merge!({ :initial_state => (item/'state').text.sanitize }) if (item/'state').length > 0

      obj = base_object.new(params)

      # Traverse across XML document and deal with elements
      item.xpath('./*').each do |attribute|

        # Do a link for elements which are links to other REST models
        if self.entry_points.keys.include?("#{attribute.name}s""#{attribute.name}s")
          obj.add_link!(attribute.name, attribute['id']) && next
        end

        # Do a HWP property for hardware profile properties
        if attribute.name == 'property'
          if attribute['value'] =~ /^(\d+)$/
            obj.add_hwp_property!(attribute['name'], attribute, :float) && next
          else
            obj.add_hwp_property!(attribute['name'], attribute, :integer) && next
          end
        end

        # If there are actions, add they to ActionObject/StateFullObject
        if attribute.name == 'actions'
          (attribute/'link').each do |link|
            obj.add_action_link!(item['id'], link)
          end && next
        end

        # Deal with collections like public-addresses, private-addresses
        if (attribute/'./*').length > 0
          obj.add_collection!(attribute.name, (attribute/'*').collect { |value| value.text }) && next
        end
        
        # Anything else is treaten as text object
        obj.add_text!(attribute.name, attribute.text.convert)
      end

      return obj
    end