Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Storing data into an xml file
Forum Updated to NodeBB v4.3 + New Features

Storing data into an xml file

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.1k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    annatz
    wrote on last edited by
    #1

    Hi,

    I have created a program that the user selects patients and their data and stores them into an xml file. My problem is that if the user selects twice the same patient, the program stores his/her data twice to the xml file.

    Is their a function that checks the file before the insertion?
    I should read the xml file first and then insert?
    Or is their an easier way to do that?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You need to read the XML file anyway, because there is no way to write out a valid XML file by simply appending. So, while you have your data in memory, you can also check it for consistency before writing out.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        WilliamU
        wrote on last edited by
        #3

        Since we do not know how your data is selected I would be inclined to keep a QMap of the selections. You can then iterate this map to create you XML, and since it is a map there would be no duplicates or prior to insert you could search the map and if the key does exists ask the user if they want to remove the already selected patient.

        --
        William

        Regards,

        William

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved