Results 1 to 4 of 4

Thread: QXmlStreamReader - read a sub document

  1. #1
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QXmlStreamReader - read a sub document

    I am using QXmlStreamReader to parse this kind of XML:

    Qt Code:
    1. <xml>
    2. <param>
    3. <name>age</name>
    4. <type>int</type>
    5. <value>42</value>
    6. </param>
    7.  
    8. <param>
    9. <name>name</name>
    10. <type>string</type>
    11. <value>dr blabla</value>
    12. </param>
    13.  
    14. <param>
    15. <name>data</name>
    16. <type>xml</type>
    17. <value>
    18. <age>12</age>
    19. <hieght>1.78 meters</height>
    20. <age>12</age>
    21. </value>
    22. </param>
    23. </xml>
    To copy to clipboard, switch view to plain text mode 

    What I need to do, is to get the whole 3rd param into a QString (or an QXmlDocument or something, not sure what is the best approach here). The problem with QXmlStreamReader is that I don't see a way to "skip" the content of this tag/node and get it as a verbatim text or something.

    What do you suggest?

  2. #2
    Join Date
    Sep 2008
    Location
    Munich
    Posts
    32
    Thanked 8 Times in 6 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QXmlStreamReader - read a sub document

    Try http://doc.qt.nokia.com/4.7-snapshot...eadElementText, this should be able to read until the closing tag is found and returns it as a QString.

  3. #3
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QXmlStreamReader - read a sub document

    jryannel,

    This returns the text inside the tags, not the "tags". In this example it will return "\n\t". Not what I am looking for.

  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: QXmlStreamReader - read a sub document

    You need to pass it the QXmlStreamReader::IncludeChildElements parameter.
    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. QXmlStreamReader
    By sophister in forum Qt Programming
    Replies: 6
    Last Post: 24th August 2011, 18:31
  2. Replies: 3
    Last Post: 3rd April 2010, 21:35
  3. Replies: 1
    Last Post: 12th January 2010, 15:59
  4. Need help with QXmlStreamReader
    By jknotzke in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 10:26
  5. QXmlStreamReader issue
    By yagabey in forum Qt Programming
    Replies: 11
    Last Post: 31st December 2008, 22:06

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.