如何在加载较大的文件时使用Tinyxml中的Loadfile()来加速
How to speed up when load a larger file use Loadfile() in Tinyxml
在我的项目中,我需要追加新的数据到xml,所以我这样做如下:问题是LoadFile()函数很慢,当xml文件很大,高cpu时,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
}
}
TinyXML有一些性能问题。RapidXML和PugiXML是首选。我不确定将代码移植到新的解析器是否容易,但是我曾经在使用TinyXML时遇到性能问题,然后切换到PugiXML。您可以查看有关c++解析器的讨论:c++最好的开放XML解析器是什么?
相关文章:
- 将成员变量添加到共享库中的类中,不会破坏二进制兼容性吗
- .cpp和.h文件中的模板专用化声明
- 反向给定链表中的K节点
- 正在查找文档以获得PS4平台的C++中的设备信息
- enum是C++中的宏变量还是整数变量
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 将字符串存储在c++中的稳定内存中
- 文本文件中的单词链表
- 递归函数计算序列中的平方和(并输出过程)
- 如何从C++中的依赖类型中获得它所依赖的类型
- C++中的"inline"关键字
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 用C++中的一个变量定义一个常量
- 检查 TinyXML 中的元素是否存在
- TinyXMl中的多线程写入数据
- 在C++中使用TinyXML在用户从openfiledialog中选择的项目之间写入换行符
- 如何在加载较大的文件时使用Tinyxml中的Loadfile()来加速
- TinyXML-2中的“TiXmlNode::FirstChild(const char *)”的替代方案是什么?
- 可编程创建的tinyxml xml文件在Internet Explorer中无法加载