public static function serialize($template)
    {
        self::ValidateLicenseResponseTemplate($template);

        $writer = new \XMLWriter();

        $writer->openMemory();
        $writer->startElementNS(null, 'PlayReadyLicenseResponseTemplate', Resources::PRL_XML_NAMESPACE);
        $writer->writeAttributeNS('xmlns', 'i', null, Resources::XSI_XML_NAMESPACE);

        self::serializeLicenseTemplates($writer, $template->getLicenseTemplates());
        $writer->writeElement('ResponseCustomData', $template->getResponseCustomData());

        $writer->endElement();

        return $writer->outputMemory();
    }