public static function loadFromXML($xml, iRandomStream $randomStream,
		&$error)
	{
		$reader = new ProtectedXMLReader($randomStream);
		if(!$reader->XML($xml) || !$reader->read(-1))
		{
			$error = "Database XML load: cannot parse the XML string.";
			$reader->close();
			return null;
		}
		if(!$reader->isElement(self::XML_KEEPASSFILE))
		{
			$error = "Database XML load: the root element is not '" . self::XML_KEEPASSFILE . "'.";
			$reader->close();
			return null;
		}
		$db = new Database();
		$db->parseXML($reader);
		$reader->close();
		if($db->_name == null && $db->_groups == null)
		{
			$error = "Database XML load: empty database.";
			return null;
		}
		$error = null;
		return $db;
	}