int CFileListXml::Onsave(const CString& strFileTemp) { CString strFile = strFileTemp; if (strFile.IsEmpty()) //调用者未设置保存路径,选择上次加载的路径 { strFile = m_strFileListXML; if (strFile.IsEmpty()) //还是空 { return Error_File_List_Path_Is_NULL; } } XML_PARSER parser; if (!parser.Load_XML_String("<?xml version=\"1.0\" encoding=\"utf-8\" ?><root version=\"2.0\"/>")) { return Error_File_List_Load_Xml_Declaration; } //项目名称 parser.Add_LastChildElement(NODE_Project); SetAttribute(parser, ATTRIBUTE_Project_Name, m_strProjectName); parser.Go_to_Root(); //X86节点及文件列表 parser.Add_LastChildElement(NODE_X86); for (vector<FILE_ITEM>::const_iterator it=m_x86FileList.begin(); it!=m_x86FileList.end(); it++) { parser.Add_LastChildElement(NODE_ITEM); SetAttribute(parser, ATTRIBUTE_ITEM_Name, it->strName); SetAttribute(parser, ATTRIBUTE_ITEM_Source_Path, it->strSrcPath); SetAttribute(parser, ATTRIBUTE_ITEM_Dest_Path, it->strDestPath); parser.Go_to_Parent(NODE_X86); } parser.Go_to_Root(); //X64节点及文件列表 parser.Add_LastChildElement(NODE_X64); for (vector<FILE_ITEM>::const_iterator it=m_x64FileList.begin(); it!=m_x64FileList.end(); it++) { parser.Add_LastChildElement(NODE_ITEM); SetAttribute(parser, ATTRIBUTE_ITEM_Name, it->strName); SetAttribute(parser, ATTRIBUTE_ITEM_Source_Path, it->strSrcPath); SetAttribute(parser, ATTRIBUTE_ITEM_Dest_Path, it->strDestPath); parser.Go_to_Parent(NODE_X64); } parser.Go_to_Root(); //保存到文件 if (!parser.Save_XML_Document(strFile)) { return Error_File_List_Unknown_Reason; } else { return Error_File_List_Success; } }