If I know the tagname of the last tag it should work:
Qt Code:
  1. void Interface::readyReadSlot()
  2. {
  3. qDebug() << "readyReadSlot()";
  4. buffer.open(QIODevice::WriteOnly);
  5. QByteArray parcel = tcpsocket->readAll();
  6. QDataStream stream(&parcel, QIODevice::ReadOnly);
  7. QString string;
  8. stream>> string;
  9. buffer.write(parcel);
  10. buffer.close();
  11. qDebug() << "parcelsize:" << QString::number(parcel.size());
  12. qDebug() << string;
  13. if(!string.contains(QRegExp("</EndTag>\n"))){
  14. qDebug() << "wait";
  15. tcpsocket->waitForReadyRead();
  16. }
  17. else
  18. emit dataWritten(block);
  19. }
To copy to clipboard, switch view to plain text mode 
if the server sends exactly one parcel this works fine, but if the server sends more than one parcels, the strings are empty and the buffer writes no data to the bytearray. So maybe the way of sending the data from server is incorrect:
Qt Code:
  1. QDataStream out(&bytearray, QIODevice::WriteOnly);
  2. QString string= message;
  3. out<< string;
  4. tcpsocket->write(bytearray);
  5.  
  6. while(!tcpsocket->waitForBytesWritten());
To copy to clipboard, switch view to plain text mode 

Why it didn't work? thank u for your help