Results 1 to 7 of 7

Thread: QXmlStreamReader

  1. #1
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy QXmlStreamReader

    Hello, I use the following xml file to store my data in the application. But when I use QXmlStreamReaderto read it into the application, it can only read the first Dish(outer label)
    The following is my data.xml
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <dish>
    3. <score>60</score>
    4. <name>11</name>
    5. <family>1</family>
    6. <season>&#26149;</season>
    7. <source>w</source>
    8. <way>wwww</way>
    9. <func>ww</func>
    10. <remark>ww</remark>
    11. </dish>
    12. <dish>
    13. <score>60</score>
    14. <name>12</name>
    15. <family>1</family>
    16. <season>&#20908;</season>
    17. <source>qq</source>
    18. <way>qq</way>
    19. <func>qq</func>
    20. <remark>qq</remark>
    21. </dish>
    22. <dish>
    23. <score>60</score>
    24. <name>2</name>
    25. <family>2</family>
    26. <season>&#31179;</season>
    27. <source>ee</source>
    28. <way>e</way>
    29. <func>e</func>
    30. <remark>e</remark>
    31. </dish>
    To copy to clipboard, switch view to plain text mode 

    Do I use the wrong formats to stroe data in an xml file.
    Thanks in advance!!

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QXmlStreamReader

    If I remember right you need a single root element:
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <dishes>
    3. <dish>...</dish>
    4. <dish>...</dish>
    5. <dish>...</dish>
    6. </dishes>
    To copy to clipboard, switch view to plain text mode 

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

    sophister (15th June 2009)

  4. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QXmlStreamReader

    @Lykurg yes, you remember right (as usual ).
    @sophister, try to open your xml file with browser and you'll see an error.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #4
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QXmlStreamReader

    Yes, it doesn't open the xml file but an error.
    Thank you both!!

  6. #5
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QXmlStreamReader

    Thanks very much!!

  7. #6
    Join Date
    Apr 2010
    Posts
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QXmlStreamReader

    Quote Originally Posted by sophister View Post
    Hello, I use the following xml file to store my data in the application. But when I use QXmlStreamReaderto read it into the application, it can only read the first Dish(outer label)
    The following is my data.xml
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <dish>
    3. <score>60</score>
    4. <name>11</name>
    5. <family>1</family>
    6. <season>春</season>
    7. <source>w</source>
    8. <way>wwww</way>
    9. <func>ww</func>
    10. <remark>ww</remark>
    11. </dish>
    12. <dish>
    13. <score>60</score>
    14. <name>12</name>
    15. <family>1</family>
    16. <season>冬</season>
    17. <source>qq</source>
    18. <way>qq</way>
    19. <func>qq</func>
    20. <remark>qq</remark>
    21. </dish>
    22. <dish>
    23. <score>60</score>
    24. <name>2</name>
    25. <family>2</family>
    26. <season>秋</season>
    27. <source>ee</source>
    28. <way>e</way>
    29. <func>e</func>
    30. <remark>e</remark>
    31. </dish>
    To copy to clipboard, switch view to plain text mode 

    Do I use the wrong formats to stroe data in an xml file.
    Thanks in advance!!
    can u tell me how you used XmlReader to take value of name ,family, season

  8. #7
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QXmlStreamReader

    Maybe you can show us your code ?

    If you just use readNext() of QXmlStreamReader, then you should encounter all the entries, of all dishes.

    Regards,
    Marc

Similar Threads

  1. Reading and rereading a file with QXmlStreamReader
    By TheRonin in forum Qt Programming
    Replies: 14
    Last Post: 30th April 2015, 14:04
  2. how QXmlStreamReader parse QString
    By SamSong in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2009, 14:56
  3. QXmlStreamReader issue
    By yagabey in forum Qt Programming
    Replies: 11
    Last Post: 31st December 2008, 21:06
  4. QXmlStreamReader error on first line?
    By warry in forum Qt Programming
    Replies: 2
    Last Post: 13th August 2008, 14:20
  5. QXmlStreamReader rewind
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 13th April 2008, 08:00

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.