View Full Version : QDomDocument or QXmlStreamWriter, QXmlStreamReader

14th December 2010, 10:24
I want to write some qt codes about writing/reading xml files. The efficiency is the first thing to be concerned! In Qt assistant, there are two kinds of classes, one is QDoms, the other is QXMLStreams!
Please give me some hints! Thank you in advance!

14th December 2010, 12:16
It really depends what you are after. "Efficiency" can mean different things.

14th December 2010, 13:06
Added after 9 minutes:

It really depends what you are after. "Efficiency" can mean different things.

My program reads the xml file entirely and sequently. And I only care about the "reading" efficiency. If the read is over, the xml file is of no use.

14th December 2010, 14:59
But does "efficiency" mean speed or memory use or disk access or what? In general QXmlStream* classes will be slightly faster when it comes to processing the data but they can become slower if your code that does the actual parsing is slow. It really depends what you want to do with the content.

14th December 2010, 16:36
Given that you do not want to manipulate the XML after reading it I would go with the stream classes, particularly if the files are large. (Dom is great for manipulating XML, but the entire data will be in memory).

Presumably, you're just reading the XML to pick out some data elements, in which case the stream will offer the fastest option.

15th December 2010, 03:25
What I care is the speed of reading. And I do not manipulate the data of the xml. So I guess the QXMLStream* is the best choice!

15th December 2010, 10:57
So why are you reading the file at all if you don't care about the content? Just don't read the file, it will be even faster.