protected function saveXML(&$data)
    {
        $this->validateParameters();
        
        $xmldoc = new \DOMDocument("1.0", "UTF-8");
        $xmldoc->formatOutput = true;
        
        $root = $xmldoc->createElement("array");
        $root = $xmldoc->appendChild($root);
        
        array_to_dom($root, $data);
        
        $xml = $xmldoc->saveXML();
        
        if (!empty($this->save_encrypted)) {
            $xml = aes_256_encrypt($xml, $this->salt_key);
        }
        
        if (file_put_contents($this->save_path, $xml) === false) {
            throw new \Exception(sprintf("The config file '%s' cannot be written!", $this->save_path));
        }
        
        return true;
    }