private function toXml($elementName, $rootElement = false)
    {
        return sprintf(
            '%s<%s%s%s>%s</%s>',
            $rootElement ? "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" : '',
            $elementName,
            $this->attributesToXml(),
            array_key_exists(get_class($this), self::$xmlNamespaces) ? sprintf(' %s', self::$xmlNamespaces[get_class($this)]) : '',
            $this->propertiesToXml(),
            $elementName
        );
    }