1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| if ( !FileExists(LOCATED + "Config.xml") )
{
TFileStream* fs = new TFileStream(LOCATED + "Config.xml",fmCreate);
delete fs;
_config = new TXpObjModel(NULL);
_config->LoadDataSource(LOCATED + "Config.xml");
_config->FormattedOutput = true;
//create processing instruction
_api = _config->Document->CreateProcessingInstruction( "xml","version=\"1.0\" encoding=\"UTF-8\"");
_config->Document->AppendChild(_api);
_api->Release();
_root = _config->Document->CreateElement("Config");
_node = _config->Document->CreateElement("status");
_textnode = _config->Document->CreateTextNode(WideString("Undone"));
_node->AppendChild(_textnode);
_root->AppendChild(_node);
_node->Release();
_textnode->Release();
_node = _config->Document->CreateElement("host");
_textnode = _config->Document->CreateTextNode(WideString("Unknown"));
_node->AppendChild(_textnode);
_root->AppendChild(_node);
_node->Release();
_textnode->Release();
_node = _config->Document->CreateElement("database");
_textnode = _config->Document->CreateTextNode(WideString("Unknown"));
_node->AppendChild(_textnode);
_root->AppendChild(_node);
_node->Release();
_textnode->Release();
_config->Document->AppendChild(_root);
_config->SaveToFile(LOCATED + "Config.xml");
_root->Release();
delete _config;
} |