In the aplication I am writing, I get a TCP socket connected to a remote serverm and trough that socket the remote site sends me a series of XML.

I used a piece of code similar to this:

Qt Code:
  1. void readData( QTcpSocket *socket )
  2. {
  3. QXmlStreamReader (socket);
  4. xml.readNextStartElement();
  6. xml.readNextStartElement();
  7. QString s =;
  8. if (s.toLower() != "root_element"){
  9. return;
  10. }
  12. while (xml.readNextStartElement()) {
  13. s =;
  14. /// more code
  15. }
  16. }
To copy to clipboard, switch view to plain text mode 

The problem is that the first XML gets read perfectly, the second XML sent is just get borked: with the remote server I get the 2nd XML borked (I trubcated XML tags). When I cat several XMLs trough "nc localhost 4444", the second XML does not even get to the application.

Can anyone help me?