tinyxml2::XMLDocument doc;
tinyxml2::XMLDeclaration * xdeclaration = doc.NewDeclaration();
xdeclaration->SetValue("
xml version=\"1.0\" encoding=\"UTF-8\"");
doc.InsertFirstChild(xdeclaration);
// first entry
tinyxml2::XMLElement *xdocument = doc.NewElement("configuration");
tinyxml2::XMLNode *xndocument = doc.InsertAfterChild(xdeclaration, xdocument);
// Section
tinyxml2::XMLElement* xeSection = doc.NewElement("section");
xeSection->SetAttribute("name", "SettingsDialog");
// Settings
tinyxml2::XMLElement *xeSettings = doc.NewElement("settings");
// enumerate Line count from sTextSettingDialog
for(int i=0; i < MAX_SETTINGSDIALOG_STRINGS; i++)
{
// convert integer(i) to string
std::string s = std::to_string(i);
char const *pchar = s.c_str();
// copy string buffer to *char
char *buffer = new char[s.length()];
strcpy(buffer,s.c_str());
// using buffer for next element
xeSettings = doc.NewElement(buffer);
// New Settings Line
xeSettings->SetValue("setting");
// First Attribut for Line(i)
xeSettings->SetAttribute("name", buffer);
// Attribute Value for Line(i)
xeSettings->SetAttribute("value", sTextSettingDialog[i]);
// End Line(i)
xeSection->InsertEndChild(xeSettings);
}
// close Document
xdocument->InsertEndChild(xeSection);
// save document file
doc.SaveFile("English.xml");