在我的项目中,我需要将新数据附加到 xml,所以我这样做如下:问题是当 xml 文件很大且 CPU 较高时,LoadFile() 函数非常慢,SaveFile() 也有同样的问题。那么,我应该如何加快我的项目。谢谢你的帮助:)
TiXmlDocument doc(m_filePath.c_str());
(void)doc.LoadFile(); //here is slowly
if (doc.Error() && (doc.ErrorId()==TiXmlBase::TIXML_ERROR_OPENING_FILE))
{
ATS_LOG(ERROR, "Can not open the file:%s", m_filePath.c_str());
result = false;
}
else
{
const TiXmlHandle docH(&doc);
TiXmlElement* const element = docH.FirstChildElement("HistoryMsgs").Element();
TiXmlNode* const pNode=element->ToElement();
if (pNode!=NULL)
{
//do something that insert new node;
(void)doc.SaveFile(m_filePath.c_str());//here is slowly too
}
}