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. Making selective changes to XML file
Forum Updated to NodeBB v4.3 + New Features

Making selective changes to XML file

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 304 Views 2 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.
  • S Offline
    S Offline
    ShakingBear
    wrote on 25 Jun 2018, 11:13 last edited by ShakingBear
    #1

    Hi,

    I am currently having a task of making that requires making selective changes to some XML.

    Lets say that the XML contains multiple elements with different tags A,B and C. I suppose to only make changes on the XML with tag B. There may be a modification / deletion / addition of the tag objects.

    In other words

    <A id ="pqr"/>
    <B id="a"/>
    <B id="1"/>
    <B id="2"/>
    <B id="3"/>
    

    can become something like:

    <A id ="pqr"/>
    <B id="3"/>
    <B id="jprs" name="somehtingOptional"/>
    

    I don't have much control over the reader (its an old code and changing it means missing all my deadlines). We now want to selectively make changes for tag B w/o affecting everything else.
    I tried using QXMLStreamWriter for this, but my implementation was basically truncate and re-write everything. Since I have no idea how tag A and C can be written (really old code and no one in the surviving team has any idea).
    I have another implementation where I am basically duplicating the data which isn't tag B and just dump it into the file later. I don't like wasting space that way.
    I tried using QDomDocument for doing this, but my setContent keeps returning false for some reason.

    I am wondering if someone can suggest me something for this. I really don't want to duplicate data (double reading, memory wastage etc.).

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 Jun 2018, 21:29 last edited by
      #2

      Hi and welcome to devnet,

      You can find the reason using the three last parameters of the setContent method.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      2/2

      25 Jun 2018, 21:29

      • Login

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