//第一种
TiXmlDocument *myDocument = new TiXmlDocument(filefullPath.c_str());
int i = myDocument->LoadFile();
if(i!=1) //表示加载不到文件,即文件不存在
{
TiXmlDocument doc1;
TiXmlDeclaration *dec=new TiXmlDeclaration("1.0","gb2312","");
TiXmlElement *matrixs=new TiXmlElement("matrixs");
doc1.LinkEndChild(dec);
doc1.LinkEndChild(matrixs);
doc1.SaveFile(filefullPath.c_str());
}
//第二种
FILE *fp;
char fname[200];
strcpy(fname,lpszFilePathxml);
fp=fopen(fname,"w+");
fprintf(fp,"%s","<?xml version=\"1.0\" encoding=\"gb2312\" ?>");
fprintf(fp,"\n%s","<matrixs>");
fprintf(fp,"\n%s","</matrixs>");
fclose(fp);