public function writeToDom($data, $rootName = 'root')
    {
        $this->buildXML(
            $dom = new DOMDocument('1.0', $this->getEncoding()),
            $root = $dom->createElement($rootName),
            $data
        );
        $dom->appendChild($root);

        return $dom;
    }