[Qt-interest] How to: parse an xml file with tags
André Somers
andre at familiesomers.nl
Tue Feb 16 21:50:13 CET 2010
All that you say may be true, but QXmlStream* is not very convenient if you
just want to modify some information in an existing XML file that you don't
know a lot about.
André
-----Oorspronkelijk bericht-----
Van: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] Namens Thiago Macieira
Verzonden: dinsdag 16 februari 2010 19:36
Aan: qt-interest at trolltech.com
Onderwerp: Re: [Qt-interest] How to: parse an xml file with tags
Em Terça-feira 16. Fevereiro 2010, às 14.33.17, Scott Aron Bloom escreveu:
> Ive been told this by Thiago on IRC multiple times... QXmlReader/
> Writer are the future, QDom is being depricated and no longer worked
> on..
>
> Ill leave it to him to discus the reasons and virtues of the move..
Correct.
QDom* classes are memory hungry and inefficient. They need the entire
document ready, then they parse it fully, before you can do anything. Sure,
it's convenient.
QXmlStreamReader and Writer are much leaner, faster and more memory
efficient.
And they operate on streams, not on full data, so they can be used to read
and parse and write very large XML files.
The inconvenience is that there's no data model for them. When coming from
QDom, people expect to be able to store their data in the class and generate
the XML on demand. That's extremely inefficient, because QDom is not meant
to store your data.
So. yes, the entire QtXml module is considered obsolete (QDom and the SAX
parser). We have no one looking at it and improving it. Fortunately, there
are no bug reports (that I know of). And the unit tests continue to pass.
If you have QDom-based code, continue to use it. But I highly recommend that
you write new code using QXmlStreamReader and Writer.
Finally, Qt 5 will probably not contain the DOM code. But since Qt 5 is
still many years away, it shouldn't be a problem now.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
More information about the Qt-interest-old
mailing list