PDA

View Full Version : QXmlStreamReader parses XML in weird order



Zeddy
23rd June 2010, 08:40
Hi, i have used the QXmlStreamReader before, but this time i ran into a problem i haven't seen earlier. What i basically try to do is loop through the document and for each start element i find i output (qDebug) the name of the element aswell as the line number it has been found on.

Now the problem is that it can suddenly do this:
line number: 2 - elementname
line number: 3 - elementname
line number: 4 - elementname
line number: 109 - elementname
line number: 110 - elementname
line number: 5 - elementname
line number: 6 - elementname
line number: 7 - elementname

What could be causing this? I tried ouputting the errors but there are no errors encountered

Thanks in advance!

Zeddy
23rd June 2010, 09:50
and this is basically the code that causes the ouput

QByteArray returnValue = route->readAll();
qDebug() << route->url();
this->theReader = new QXmlStreamReader(returnValue);
while(!this->theReader->atEnd()){
this->theReader->readNext();
if(this->theReader->isStartElement()){
qDebug() << this->theReader->name().toString() << this->theReader->lineNumber();
}
}

and here is the output generated:

[Qt Message] "MTRXML" 2
[Qt Message] "MAPLOC" 99
[Qt Message] "ROUTE" 3
[Qt Message] "NAME" 357
[Qt Message] "NAME" 358
[Qt Message] "LENGTH" 4
[Qt Message] "POINT" 5
[Qt Message] "ARRIVAL" 6
[Qt Message] "DEPARTURE" 7
[Qt Message] "WALK" 9
[Qt Message] "LENGTH" 10
[Qt Message] "POINT" 11
[Qt Message] "ARRIVAL" 12
[Qt Message] "DEPARTURE" 13
[Qt Message] "MAPLOC" 15
[Qt Message] "ARRIVAL" 16
[Qt Message] "DEPARTURE" 17
[Qt Message] "NAME" 18
[Qt Message] "MAPLOC" 20
[Qt Message] "ARRIVAL" 21
[Qt Message] "DEPARTURE" 22
[Qt Message] "MAPLOC" 24
[Qt Message] "ARRIVAL" 25
[Qt Message] "DEPARTURE" 26
[Qt Message] "NAME" 27
[Qt Message] "MAPLOC" 29
[Qt Message] "ARRIVAL" 30
[Qt Message] "DEPARTURE" 31
[Qt Message] "NAME" 32
[Qt Message] "MAPLOC" 34
[Qt Message] "ARRIVAL" 35
[Qt Message] "DEPARTURE" 36
[Qt Message] "NAME" 37
[Qt Message] "STOP" 39
[Qt Message] "ARRIVAL" 40
[Qt Message] "DEPARTURE" 41
[Qt Message] "NAME" 42
[Qt Message] "NAME" 43
[Qt Message] "LINE" 46
[Qt Message] "LENGTH" 47
[Qt Message] "STOP" 48
[Qt Message] "ARRIVAL" 49
[Qt Message] "DEPARTURE" 50
[Qt Message] "NAME" 51
[Qt Message] "NAME" 52
[Qt Message] "STOP" 54
[Qt Message] "ARRIVAL" 55
[Qt Message] "DEPARTURE" 56
[Qt Message] "NAME" 57
[Qt Message] "NAME" 58
[Qt Message] "STOP" 60
[Qt Message] "ARRIVAL" 61
[Qt Message] "DEPARTURE" 62

Zeddy
23rd June 2010, 09:57
heres the xml, had to cut out parts of it though
http://pastebin.com/NAPzs51w

edit: now im starting to realise that the parser stops at line 62 when it should actually continue for hundreads of rows, what could be the cause of this, invalid format on the XML?