View Full Version : QXStreamreader' readnext function
yagabey
30th January 2009, 15:10
Hello,
I am trying to parse an xml doc. Considering the following xml data:
<item>
<title>New champion..</title>
<link>
http://www.radikal.com.tr/Radikal.aspx?aType=RadikalHaberDetay&ArticleID=919267&CategoryID=103
</link>
<description>http://www.radikal.com.tr/2009/01/30/</description>
</item>
When i try to read the "link" parameter:
if (current == "link"){
link = reader->text().toString();
reader->readNext();
}
"link" returns "http://www.radikal.com.tr/Radikal.aspx?aType=RadikalHaberDetay"
when once more i read next:
reader->readNext();
"link" returns "&ArticleID=919267" and once more...:
reader->readNext();
"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..
caduel
30th January 2009, 16:47
are you sure you don't have to escape those &s to & in your xml?
yagabey
31st January 2009, 00:07
Do you mean, i should parse it after replacing &s?
yagabey
31st January 2009, 11:52
I replaced "&" s by "&"s ; but the result didn't change.It behaves same..
seneca
31st January 2009, 12:23
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?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bpsreport>
<report name="New Report" paper="0" orientation="0" papersize="210,297" margins="10,10,10,10">
<script></script>
<section name="Section 1" height="20" position="0" autogrow="true">
<simpletext name="Simple text 1" zvalue="0" pos="36,7" size="145,8"
font="MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0" color="#ff000000" margins="0,0,0,0"
alignment="3" direction="0" roundness="0" pen="0,0,#ff000000" brush="0,100,#ff000000">
<text>http://www.radikal.com.tr/Radikal.aspx?aType=RadikalHaberDetay&ArticleID=919 267&CategoryID=103</text>
</simpletext>
</section>
</report>
yagabey
31st January 2009, 12:41
Actually it is an rss file, it has no xml header; but it has an rss header:
<rss version="2.0">
Does it make any difference for QXmlstreamreader?
seneca
31st January 2009, 12:58
Actually also RSS should have a valid XML header. Here is a sample from the specifications (http://cyber.law.harvard.edu/rss/rss.html):
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>Liftoff News</title>
<link>http://liftoff.msfc.nasa.gov/</link>
...
yagabey
31st January 2009, 17:26
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:
<?xml version="1.0" encoding="UTF-8" ?>
<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/">
So they exist, why does QXmlStreamreader behave diferent for you and me :eek: :confused:
seneca
31st January 2009, 17:46
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
.
yagabey
1st February 2009, 00:54
No luck...QXmlStreamreader continues to split "link"...
Anyway i made my application work in another tricky way..Thanks for help..
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.