Results 1 to 10 of 10

Thread: QXStreamreader' readnext function

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default QXStreamreader' readnext function

    Hello,

    I am trying to parse an xml doc. Considering the following xml data:

    Qt Code:
    1. <item>
    2. <title>New champion..</title>
    3. <link>
    4. http://www.radikal.com.tr/Radikal.aspx?aType=RadikalHaberDetay&ArticleID=919267&CategoryID=103
    5. </link>
    6. <description>http://www.radikal.com.tr/2009/01/30/</description>
    7. </item>
    To copy to clipboard, switch view to plain text mode 

    When i try to read the "link" parameter:

    Qt Code:
    1. if (current == "link"){
    2. link = reader->text().toString();
    3. reader->readNext();
    4. }
    To copy to clipboard, switch view to plain text mode 

    "link" returns "http://www.radikal.com.tr/Radikal.aspx?aType=RadikalHaberDetay"

    when once more i read next:

    Qt Code:
    1. reader->readNext();
    To copy to clipboard, switch view to plain text mode 

    "link" returns "&ArticleID=919267" and once more...:

    Qt Code:
    1. reader->readNext();
    To copy to clipboard, switch view to plain text mode 

    "link" returns "&CategoryID=103".

    QXmlStreamreader splits "link" into three pieces(on "&" sections). I want to get all "link" in one read step. How can i achieve that?

    Thanks in advance..

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QXStreamreader' readnext function

    are you sure you don't have to escape those &s to &amp; in your xml?

  3. #3
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QXStreamreader' readnext function

    Do you mean, i should parse it after replacing &s?

  4. #4
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QXStreamreader' readnext function

    I replaced "&" s by "&amp;"s ; but the result didn't change.It behaves same..

  5. #5
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QXStreamreader' readnext function

    I entered you link as text in my Qt based report designer, and it saves and loads without problem with QXmlStreamReader. Below is the exported file fyi. Do you have a proper xml header in your file?

    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <!DOCTYPE bpsreport>
    3. <report name="New Report" paper="0" orientation="0" papersize="210,297" margins="10,10,10,10">
    4. <script></script>
    5. <section name="Section 1" height="20" position="0" autogrow="true">
    6. <simpletext name="Simple text 1" zvalue="0" pos="36,7" size="145,8"
    7. font="MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0" color="#ff000000" margins="0,0,0,0"
    8. alignment="3" direction="0" roundness="0" pen="0,0,#ff000000" brush="0,100,#ff000000">
    9. <text>http://www.radikal.com.tr/Radikal.aspx?aType=RadikalHaberDetay&amp;ArticleID=919267&amp;CategoryID=103</text>
    10. </simpletext>
    11. </section>
    12. </report>
    To copy to clipboard, switch view to plain text mode 
    Last edited by seneca; 31st January 2009 at 11:29.

  6. #6
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QXStreamreader' readnext function

    Actually it is an rss file, it has no xml header; but it has an rss header:

    Qt Code:
    1. <rss version="2.0">
    To copy to clipboard, switch view to plain text mode 

    Does it make any difference for QXmlstreamreader?

  7. #7
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QXStreamreader' readnext function

    Actually also RSS should have a valid XML header. Here is a sample from the specifications:

    Qt Code:
    1. <?xml version="1.0"?>
    2. <rss version="2.0">
    3. <channel>
    4. <title>Liftoff News</title>
    5. <link>http://liftoff.msfc.nasa.gov/</link>
    6. ...
    To copy to clipboard, switch view to plain text mode 
    Last edited by seneca; 31st January 2009 at 12:11.

  8. #8
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QXStreamreader' readnext function

    Oh my God..It already had all headers..I was opening the xml doc with firefox...So it does not show the headers..Sorry silly mistake :-)

    Returning to the problem...The actual headers are:

    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8" ?>
    2. <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/">
    To copy to clipboard, switch view to plain text mode 

    So they exist, why does QXmlStreamreader behave diferent for you and me

  9. #9
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QXStreamreader' readnext function

    Hmm, since you are using namespace, would enabling them with setNamespaceProcessing (true) make a difference?

    Other ideas:

    • try to read my file above, to find if the file is to blame
    • check for errors after every method call
    • I am using 4.4.3, with older releases I had problems with formated xml files
    .

  10. #10
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QXStreamreader' readnext function

    No luck...QXmlStreamreader continues to split "link"...
    Anyway i made my application work in another tricky way..Thanks for help..

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.