In my project I need append new data to a xml, so I do it like below: the question is the LoadFile() funcation is so slowly when the xml file is large, and high-cpu, the SaveFile() have same problem. So, How should I speed up in my project. Thanks you help:)
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
}
}