Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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.

    Thanks



  • 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

    Hi,

    For more information, you can read the documentation of "QXmlContentHandler":http://qt-project.org/doc/qt-5/qxmlcontenthandler.html

    Hope it helps


Log in to reply