Important: Please read the Qt Code of Conduct -

StartDocument() method: Usage

  • Hi All,

    I am not able to grasp what exactly does the startDocument() method does when parsing an XML document.

    In my text book the following is given;

    bool myHandler::startDocument(){

    indent =" " // indent is a QString object

    return true;


    I cannot understand why this is required as there is no testing that is done.


  • Just to add to the above.

    The methods that were used in the derived MyHandler class (derived/sub-classed from QXmlDefaultHandler class) are

    bool startDocument()
    bool startElement(....)
    bool characters(....)
    bool endElement(....)

    I am assuming the return types are bool because if there is a problem with the XML document it will through an error and stops. Else it continues?

  • Lifetime Qt Champion


    For more information, you can read the documentation of "QXmlContentHandler":

    Hope it helps

Log in to reply