QDomDocument or QXmlStreamWriter, QXmlStreamReader
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!
Re: QDomDocument or QXmlStreamWriter, QXmlStreamReader
It really depends what you are after. "Efficiency" can mean different things.
Re: QDomDocument or QXmlStreamWriter, QXmlStreamReader
Added after 9 minutes:
Quote:
Originally Posted by
wysota
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.
Re: QDomDocument or QXmlStreamWriter, QXmlStreamReader
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.
Re: QDomDocument or QXmlStreamWriter, QXmlStreamReader
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.
Re: QDomDocument or QXmlStreamWriter, QXmlStreamReader
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!
Re: QDomDocument or QXmlStreamWriter, QXmlStreamReader
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.