[Qt-interest] How to: parse an xml file with tags
Thiago Macieira
thiago at kde.org
Tue Feb 16 19:36:29 CET 2010
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100216/f27c5468/attachment.bin
More information about the Qt-interest-old
mailing list