Results 1 to 7 of 7

Thread: QDomDocument or QXmlStreamWriter, QXmlStreamReader

  1. #1
    Join Date
    Aug 2008
    Location
    Nanjing, China
    Posts
    66
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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!
    Jerry

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDomDocument or QXmlStreamWriter, QXmlStreamReader

    It really depends what you are after. "Efficiency" can mean different things.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2008
    Location
    Nanjing, China
    Posts
    66
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDomDocument or QXmlStreamWriter, QXmlStreamReader


    Added after 9 minutes:


    Quote Originally Posted by wysota View Post
    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.
    Last edited by calmspeaker; 14th December 2010 at 12:12. Reason: updated contents
    Jerry

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2010
    Posts
    52
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default 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.

  6. #6
    Join Date
    Aug 2008
    Location
    Nanjing, China
    Posts
    66
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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!
    Jerry

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Multiline comment with QXmlStreamWriter
    By QtWannabe in forum Qt Programming
    Replies: 2
    Last Post: 30th November 2010, 13:05
  2. QXmlStreamWriter UTF-16 Problem
    By 27Loco in forum Qt Programming
    Replies: 3
    Last Post: 7th July 2010, 13:04
  3. Readable Xml with QXmlStreamWriter
    By jano_alex_es in forum Newbie
    Replies: 8
    Last Post: 26th August 2009, 11:53
  4. Split QDomDocument to new QDomDocument
    By estanisgeyer in forum Qt Programming
    Replies: 4
    Last Post: 28th January 2009, 09:59
  5. QDomDocument inside other QDomDocument
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2008, 15:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.