Making selective changes to XML file
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.).
Hi and welcome to devnet,
You can find the reason using the three last parameters of the