保存:
//xml的实体 TiXmlElement* rootElement = new TiXmlElement("spark"); rootElement->SetAttribute("name", m_sParticleName.c_str()); //建立xml用于保存 TiXmlDocument *doc = new TiXmlDocument; //声明 TiXmlDeclaration *dec = new TiXmlDeclaration("1.0", "utf-8", ""); doc->LinkEndChild(dec); doc->LinkEndChild(rootElement); doc->SaveFile(_xmlOutFilePath.c_str());
读取:
TiXmlDocument *doc = new TiXmlDocument; doc->LoadFile(_xmlFilePath.c_str());