0
在我的项目中,我需要将新数据附加到xml,所以我这样做如下: 问题是LoadFile()函数是如此之慢xml文件很大,而high-cpu,SaveFile()也有同样的问题。所以,我应该如何加快我的项目。 感谢您的帮助:)加载大文件时如何加速使用Tinyxml中的Loadfile()
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
}
}