Results 1 to 12 of 12

Thread: QXmlStreamReader issue

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

    Default QXmlStreamReader issue

    Hello friends,
    I am parsing an xml document by using a QXmlStreamReader object (reader)
    It works good; but sometimes it adds an escape character ( \a ) at the end of the text(sometimes also to the beginning) read from xml doc. For example:

    Qt Code:
    1. searchedLink = reader.text().toString();
    To copy to clipboard, switch view to plain text mode 
    searchedLink = "http://www.sabah.com.tr/2008/12/31/haber,488A30CE223F4E15842D3606D3FE2880.html\a"
    instead of
    "http://www.sabah.com.tr/2008/12/31/haber,488A30CE223F4E15842D3606D3FE2880.html"
    athough there is no "\a" at the end of the link in the original xml doc.
    What may be the cause of that situation?

    To fix this, I tried:

    Qt Code:
    1. searchedLink.remove("\a",Qt::CaseInsensitive)
    To copy to clipboard, switch view to plain text mode 
    But, remove function can't find "\a" character (an escape character issue, it think)
    How can i remove an escape character?

    Thanks in advance..

  2. #2
    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 issue

    try this
    Qt Code:
    1. searchedLink.remove("\\a",Qt::CaseInsensitive)
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  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: QXmlStreamReader issue

    Hello spirit,

    Qt Code:
    1. searchedLink.remove("\\a",Qt::CaseInsensitive)
    To copy to clipboard, switch view to plain text mode 

    didnt work

    more over;
    Qt Code:
    1. searchedLink.contains("\\a")
    To copy to clipboard, switch view to plain text mode 
    returns false although searchedLink contains "\a"

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QXmlStreamReader issue

    Quote Originally Posted by yagabey View Post
    returns false although searchedLink contains "\a"
    Are you sure? If you assign it by hand like this:
    Qt Code:
    1. searchedLink = "http://www.sabah.com.tr/2008/12/31/haber,488A30CE223F4E15842D3606D3FE2880.html\a"
    To copy to clipboard, switch view to plain text mode 
    then it won't contain "\a". The escape character needs to be escaped here as well:
    Qt Code:
    1. searchedLink = "http://www.sabah.com.tr/2008/12/31/haber,488A30CE223F4E15842D3606D3FE2880.html\\a"
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    Default Re: QXmlStreamReader issue

    Are you sure? If you assign it by hand like this:
    It is in the form ".....html\a" . Actually i don't assign it; that is what the reader reads to me; and I want to remove that "\a". Because i will give this link to QHttp (It will give an error with "\a") .

  6. #6
    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 issue

    remove two last characters.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

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

    Default Re: QXmlStreamReader issue

    posibble
    but it is sometimes at the beginning, sometimes at the end, sometimes both, sometimes none ...

  8. #8
    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 issue

    Quote Originally Posted by spirit View Post
    remove two last characters.
    \a is one character, not two.

    Quote Originally Posted by yagabey View Post
    Actually i don't assign it; that is what the reader reads to me;
    Are you sure it is what the reader does? QXmlStreamReader doesn't modify the contents you pass to it, maybe the extra character:
    a) is not there at all
    b) was there before parsing with the xml parser

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

    Default Re: QXmlStreamReader issue

    a) is not there at all
    believe me, it is there..

    b) was there before parsing with the xml parser
    it wasnt there...

    What i am doing is that: By using a link Iam connecting and getting the rss content of a news site. From the rss content, i am parsing the links. After that i am connecting to that link and getting a text doc.
    That "\a" character problem occurs when reading the link part on some websites. For example that one:
    http://www.milliyet.com.tr/D/rss/rss/RssY.xml

    But for some of the sites there is no such problem..

  10. #10
    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 issue

    Quote Originally Posted by wysota View Post
    \a is one character, not two.
    if you are talking of C++ context then you are right, if you are talking in plain text context then you are wrong, because slash "\" and "a" two different characters. I was talking about plain text context.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  11. #11
    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

    But C functions are executed in C context so stripping two characters would strip two characters in C context not in source code context - 0x6F is a single character not four

    Quote Originally Posted by yagabey View Post
    What i am doing is that: By using a link Iam connecting and getting the rss content of a news site. From the rss content, i am parsing the links. After that i am connecting to that link and getting a text doc.
    That "\a" character problem occurs when reading the link part on some websites. For example that one:
    http://www.milliyet.com.tr/D/rss/rss/RssY.xml

    But for some of the sites there is no such problem..
    Could you provide a minimal compilable example reproducing the problem? Also try QString::simplified() and QString::trimmed(), they should work for you.

  12. #12
    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 issue

    Quote Originally Posted by wysota View Post
    But C functions are executed in C context so stripping two characters would strip two characters in C context not in source code context - 0x6F is a single character not four
    .
    in this context I agree with you.
    PS: Happy New Year
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Mysterious QXMLStreamReader parsing behavior
    By ym1206 in forum Qt Programming
    Replies: 3
    Last Post: 14th June 2010, 19:56
  2. Replies: 1
    Last Post: 28th October 2008, 16:29
  3. qt4.4 pc specs requirements or qt3 support issue?
    By triperzonak in forum Installation and Deployment
    Replies: 0
    Last Post: 9th August 2008, 02:40
  4. qt3 to qt4 - uic issue
    By hvengel in forum Qt Programming
    Replies: 10
    Last Post: 4th March 2007, 02:59
  5. Replies: 5
    Last Post: 22nd September 2006, 08:04

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.