PDA

View Full Version : QXmlStreamReader issue



yagabey
31st December 2008, 11:31
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:


searchedLink = reader.text().toString();
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:


searchedLink.remove("\a",Qt::CaseInsensitive)
But, remove function can't find "\a" character (an escape character issue, it think)
How can i remove an escape character?

Thanks in advance..

spirit
31st December 2008, 11:41
try this


searchedLink.remove("\\a",Qt::CaseInsensitive)

yagabey
31st December 2008, 12:22
Hello spirit,


searchedLink.remove("\\a",Qt::CaseInsensitive)

didnt work

more over;

searchedLink.contains("\\a")
returns false although searchedLink contains "\a"

jpn
31st December 2008, 12:30
returns false although searchedLink contains "\a"
Are you sure? If you assign it by hand like this:


searchedLink = "http://www.sabah.com.tr/2008/12/31/haber,488A30CE223F4E15842D3606D3FE2880.html\a"

then it won't contain "\a". The escape character needs to be escaped here as well:


searchedLink = "http://www.sabah.com.tr/2008/12/31/haber,488A30CE223F4E15842D3606D3FE2880.html\\a"

yagabey
31st December 2008, 12:41
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") .

spirit
31st December 2008, 14:06
remove two last characters. :cool:

yagabey
31st December 2008, 17:45
posibble;)
but it is sometimes at the beginning, sometimes at the end, sometimes both, sometimes none ...

wysota
31st December 2008, 17:54
remove two last characters. :cool:

\a is one character, not two.


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

yagabey
31st December 2008, 18:19
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..

spirit
31st December 2008, 19:37
\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.

wysota
31st December 2008, 20:14
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 :)


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.

spirit
31st December 2008, 21:06
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 :D