private function decodeValue($value) {

        $children = $value->children();

        if ( count($children) != 1 ) throw new XmlrpcException("Cannot decode value: invalid value element");

        $child = $children[0];

        $child_type = $child->getName();

        switch ( $child_type ) {

            case "i4":
            case "int":
                $return_value = $this->decodeInt($child);
            break;

            case "double":
                $return_value = $this->decodeDouble($child);
            break;

            case "boolean":
                $return_value = $this->decodeBool($child);
            break;

            case "base64":
                $return_value = $this->decodeBase($child);
            break;
            
            case "dateTime.iso8601":
                $return_value = $this->decodeIso8601Datetime($child);
            break;

            case "string":
                $return_value = $this->decodeString($child);
            break;

            case "array":
                $return_value = $this->decodeArray($child);
            break;
            
            case "struct":
                $return_value = $this->decodeStruct($child);
            break;
            
            case "nil":
            case "ex:nil":
                $return_value = $this->decodeNil();
            break;
            
            default:
                throw new XmlrpcException("Cannot decode value: invalid value type");
            break;

        }

        return $return_value;

    }