c++ - 使用 Qt 框架解析指定标签的 XML 文件的最快方法

标签 c++ performance qt xml-parsing

据我所知,有 4 种使用 C++ 和 Qt 解析 XML 文件的方法。

QDom
QSax
QXMLStreamReader
QXMLQuery

我在我的文件中搜索具有特定属性的节点,如果找到它,我将中止解析并将文件名保存到列表中并解析下一个文件。 我使用 QDom 完成了这项工作,但由于我搜索了多达 10k 个文件,每个文件大约有 400 行。解析它们需要一些时间。

我的问题是你们中是否有人知道这些不同方法的性能? 或者您是否有任何提高此类程序性能的技巧?

我很感激任何信息!

最佳答案

我认为,如果您不能从 xml 文件中获取树结构,请使用 QXMLStremReader。

QXmlStreamReader is the fastest and easiest way to read XML in Qt. Because the parser works incrementally, it is particularly useful for finding all occurrences of a given tag in an XML document, for reading very large files that may not fit in memory, and for populating custom data structures to reflect an XML document's contents.

关于c++ - 使用 Qt 框架解析指定标签的 XML 文件的最快方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12948152/

相关文章:

CreateFile() 在 Qt Creator 中不起作用?

c++ - 模板参数组合排序

c++ - 在堆而不是栈上初始化 C++ 结构体

c++ - JavaScript 和 VBScript 中与 GetObject 等效的 C++ 是什么?

asp.net - 有哪些用于性能测试 SharePoint Web 部件和控件的好技术?

c++ - 在 Qt 中用几个不同的流读取同一个文件

c++ - 运算符重载未处理的异常

java - 存储过程与单例 Java

java - postInstantiate buildSessionFactory 慢/内存巨大的数据库

java - 如何在Qt中使用JNI创建字符串数组