Results 1 to 3 of 3

Thread: QDomDocument or QXmlStreamReader

  1. #1
    Join Date
    Jun 2014
    Posts
    14
    Thanks
    3
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default QDomDocument or QXmlStreamReader

    I've got an XML response, and I'm wondering which method is best to use to obtain the required information I need. I want to run through the XML, looking for specific elements and checking the text within.
    Current code:

    Qt Code:
    1. QXmlStreamReader sr(response);
    2.  
    3. while (!sr.atEnd())
    4. {
    5. sr.readNext();
    6.  
    7. if(sr.name() == "FeedSubmissionId")
    8. {
    9. QByteArray FeedSubmissionID = sr.readElementText().toUtf8();
    10. GetFeedSubmissionList(FeedSubmissionID);
    11. }
    12. }
    13. if (sr.hasError())
    14. {
    15. QString err = sr.errorString();
    16. qDebug() << err;
    17. }
    To copy to clipboard, switch view to plain text mode 


    Any advice would be much appreciated.

    Regards,

    Richard
    Last edited by Poonarge; 14th July 2014 at 10:05.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QDomDocument or QXmlStreamReader

    If you are only interested in certain parts then I'd say QXmlStreamReader.
    It lets you skip whatever you are not interested in.

    QDomDocument needs to parse the whole XML document into an internal memory tree.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Poonarge (14th July 2014)

  4. #3
    Join Date
    Jun 2014
    Posts
    14
    Thanks
    3
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QDomDocument or QXmlStreamReader

    Ok, thanks, will do that

Similar Threads

  1. QXmlStreamReader help?
    By nthung in forum Newbie
    Replies: 2
    Last Post: 4th October 2011, 09:03
  2. QDomDocument or QXmlStreamWriter, QXmlStreamReader
    By calmspeaker in forum Qt Programming
    Replies: 6
    Last Post: 15th December 2010, 09:57
  3. Need help with QXmlStreamReader
    By jknotzke in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 09:26
  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

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.