public static function deserialize($template)
    {
        $xml = simplexml_load_string($template);
        $result = new PlayReadyLicenseResponseTemplate();

        // Validation
        if ($xml->getName() !== 'PlayReadyLicenseResponseTemplate') {
            throw new \RuntimeException("This is not a PlayReadyLicenseResponseTemplate, it is a '{$xml->getName()}'");
        }
        if (!isset($xml->LicenseTemplates)) {
            throw new \RuntimeException(
                "The PlayReadyLicenseResponseTemplate must contains an 'LicenseTemplates' element"
            );
        }

        // decoding
        $result->setLicenseTemplates(self::deserializeLicenseTemplates($xml->LicenseTemplates));

        if (isset($xml->ResponseCustomData)) {
            $result->setResponseCustomData((string) $xml->ResponseCustomData);
        }

        self::ValidateLicenseResponseTemplate($result);

        return $result;
    }