QXStreamreader' readnext function
Hello,
I am trying to parse an xml doc. Considering the following xml data:
Code:
<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:
Code:
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:
Code:
reader->readNext();
"link" returns "&ArticleID=919267" and once more...:
Code:
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..
Re: QXStreamreader' readnext function
are you sure you don't have to escape those &s to & in your xml?
Re: QXStreamreader' readnext function
Do you mean, i should parse it after replacing &s?
Re: QXStreamreader' readnext function
I replaced "&" s by "&"s ; but the result didn't change.It behaves same..
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?
Code:
<?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=919267&CategoryID=103</text>
</simpletext>
</section>
</report>
Re: QXStreamreader' readnext function
Actually it is an rss file, it has no xml header; but it has an rss header:
Code:
<rss version="2.0">
Does it make any difference for QXmlstreamreader?
Re: QXStreamreader' readnext function
Actually also RSS should have a valid XML header. Here is a sample from the specifications:
Code:
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>Liftoff News</title>
<link>http://liftoff.msfc.nasa.gov/</link>
...
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:
Code:
<?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:
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
.
Re: QXStreamreader' readnext function
No luck...QXmlStreamreader continues to split "link"...
Anyway i made my application work in another tricky way..Thanks for help..