Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Editing XML file from Qt

    General and Desktop
    5
    7
    529
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      VJain85 last edited by

      Can anyone tell how can I edit an XML file from my Qt C++ code?

      jsulm JonB 2 Replies Last reply Reply Quote 0
      • JohanSolo
        JohanSolo last edited by JohanSolo

        You can use the (deprecated) QtXml module, or the StAX API, directly in Qt core IIRC.

        `They did not know it was impossible, so they did it.'
        -- Mark Twain

        1 Reply Last reply Reply Quote 4
        • jsulm
          jsulm Lifetime Qt Champion @VJain85 last edited by

          @VJain85 https://doc.qt.io/qt-5/qtxml-index.html

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 4
          • JonB
            JonB @VJain85 last edited by

            @VJain85
            Note that I have used this QtXML module for some work, and it was fine. I think it is deprecated because nobody wants to maintain it, and it might have some oddities, rather than because it does not work or goes wrong.

            1 Reply Last reply Reply Quote 0
            • V
              VJain85 last edited by

              can we do this using SAX handler?

              mrjj JonB 2 Replies Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion @VJain85 last edited by

                @VJain85
                What do you mean by SAX handler ?

                The QXmlStreamReader is a SAX interface.

                1 Reply Last reply Reply Quote 2
                • JonB
                  JonB @VJain85 last edited by

                  @VJain85
                  If you want to do your processing via the QXmlStreamReader/Writer SAX-type parser that is fine. Note however that means you will not be editing the XML "in place"/"in memory", instead you will be reading the file incrementally and outputting the edited XML to a new file as you go along.

                  1 Reply Last reply Reply Quote 5
                  • First post
                    Last post