Documentation confusion QXmlStreamReader::readNextStartElement

  • Hi,

    I am using "QXmlStreamReader::readNextStartElement" to parse an exm stream. The data is read from a network socket, I am using the following method.

    @mysocket mysock;
    QXmlStreamReader xmlreader;
    char buff[1024];
    int outlen=0;
    int err;
    QByteArray byteArray(buff,outlen);
    case QXmlStreamReader::NoError:
    case QXmlStreamReader::PrematureEndOfDocumentError:
    //some code to break the infinite while loop


    In the code at line 8 & 9, if the "bytearray" is not fully parsed, whether the existing unparsed data will be lost? If so is there any alternative?

    And "readNextStartElement()" some times returns false, but when I check the error status using "error()" call, it returns "NoError"! Why this is happening?


  • Hello.

    I don't understand why any data should be partially parsed in line 8 or 9. Neither of these lines does any parsing as far as I can tell.

    The documentation of QXmlStreamReader::readNextStartElement states:

    bq. Returns true when a start element was reached. When the end element was reached, or when an error occurred, false is returned.

    So I guess when you see a false return value and now Error you just read the end element.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.