前端之家收集整理的这篇文章主要介绍了
wxwidgets中对全局数据以xml文件的形式进行保存,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
主要以学生的英语成绩记录为一个例子
void SaveXmlFile()
{
wxXmlNode* sp_project = new wxXmlNode(NULL,wxXML_ELEMENT_NODE,wxT("project"));
wxXmlNode* sp_name= new wxXmlNode(NULL,wxT("name"));
wxXmlNode* sp_grade = new wxXmlNode(NULL,wxT("grade"));
wxXmlNode* sp_score= new wxXmlNode(NULL,wxT("score"));
sp_project->AddChild(sp_name);
sp_project->AddChild(sp_grade);
sp_project->AddChild(sp_score);
wxXmlNode *m_sp_name = new wxXmlNode(wxXML_TEXT_NODE,wxEmptyString,wxT("name"));
sp_name->AddChild(m_sp_name);
wxXmlNode* node_grade = new wxXmlNode(NULL,wxT("gradeOne"));
int a=2
wxString msg;
msg.Printf(wxT("%d"),a);
wxXmlNode *m_node_grade = new wxXmlNode(wxXML_TEXT_NODE,msg);
sp_gif->AddChild(node_grade);
wxXmlNode *score = new wxXmlNode(NULL,wxT("English"));
sp_images->AddChild(score);
wxXmlNode *m_score = new wxXmlNode(wxXML_TEXT_NODE,"90");
path->AddChild(m_score);
for(int i=0;i<score_count;i++) //score_count该年级的学生人数
{
path = new wxXmlNode(NULL,wxT("English"));
sp_score->AddChild(score);
m_path = new wxXmlNode(wxXML_TEXT_NODE,"80");
path->AddChild(m_score);
}
wxXmlDocument doc;
doc.SetRoot(sp_project);
doc.Save("congif.xml");
}
原文链接:https://www.f2er.com/xml/298270.html