<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div><span>Well, you need to add another layer in. There are two easy ways to do that:</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">1. Look for the start sentinel and send everything before that to the XML reader,</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">2. or encapsulate them into QDataStream and read each doc as a string from the stream. </div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande',
 sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">If you are using streaming for document size issues, then 1. If you don't trust your parsing, then 2.</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">Either way its a just a few lines of code. </div><div><br></div>  <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size:
 10pt;"> <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1">  <font size="2" face="Arial"> <b><span style="font-weight:bold;">From:</span></b> Sze Howe Koh <szehowe.koh@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> "interest@qt-project.org" <interest@qt-project.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Sunday, December 8, 2013 6:57 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> [Interest] QXmlStreamReader: Processing multiple documents from   QTcpSocket<br> </font> </div> <div class="y_msg_container"><br>Hello,<br><br>For a networked app, I created an XML-based communications protocol<br>over TCP (a bit like SOAP).<br><br>At first, I let QXmlStreamReader read directly from QTcpSocket. When<br>an EndDocument token is found, I'd call QXmlStreamReader::clear() and<br>setDevice(), to wait for
 the next message from the same socket.<br><br>This arrangement worked really well initially. However, I noticed that<br>if 2 messages were sent in quick succession, the end of the 1st XML<br>document and the start of the 2nd document would be received as a<br>single chunk of text. The result is an "XML declaration not at start<br>of document" error (or "Extra content at end of document", if the XML<br>declaration was omitted).<br><br>The only way I can think of around this problem is to parse the data<br>from the QTcpSocket, delimit it manually, then pass a single XML<br>document into QXmlStreamReader. This requires me to implement a<br>minimal XML parser myself though -- is there a nicer way?<br><br>It would be great if QXmlStreamReader can play nicely with data<br>streamed over a network. Would it be reasonable to ask for an option<br>that lets QXmlStreamReader receive multiple documents during
 its<br>lifetime?<br><br><br>Regards,<br>Sze-Howe<br>_______________________________________________<br>Interest mailing list<br><a ymailto="mailto:Interest@qt-project.org" href="mailto:Interest@qt-project.org">Interest@qt-project.org</a><br><a href="http://lists.qt-project.org/mailman/listinfo/interest" target="_blank">http://lists.qt-project.org/mailman/listinfo/interest</a><br><br><br></div> </div> </div>  </div></body></html>