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. How to write specific tag in existing XML using QXmlStreamWriter ?
Forum Update on Monday, May 27th 2025

How to write specific tag in existing XML using QXmlStreamWriter ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 159 Views
  • 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.
  • M Offline
    M Offline
    MECoder
    wrote on 23 Mar 2023, 15:46 last edited by MECoder
    #1

    Hello,
    i have an existing XML file that i parse with QXmlStreamReader, calculate somre results and later i want to write these results to the existing XML directly into the tag
    <Results>
    </Results>
    My problem is to finde this tag within the XML file with the QXmlStreamWriter class. Sure, i can find the StartElement <Results> with QXmlStreamReader, but how does this
    help. How can i write to a specific tag in an existing XML file without writing the complete XML fiel again?
    Can anyone give me a hint?
    Thx

    The XML looks like this and between the tags Data and Points a lot of other tags.

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <Calibration version="0.5">
    	<Sensor sn="" type="">
    		<BinFile></BinFile>
    		<Data>
    		</Data>
    		<Points>
    		</Points>
    		<Results>
    		</Results>
    	</Sensor>
    </Calibration>
    
    
    J 1 Reply Last reply 23 Mar 2023, 16:17
    0
    • M MECoder
      23 Mar 2023, 15:46

      Hello,
      i have an existing XML file that i parse with QXmlStreamReader, calculate somre results and later i want to write these results to the existing XML directly into the tag
      <Results>
      </Results>
      My problem is to finde this tag within the XML file with the QXmlStreamWriter class. Sure, i can find the StartElement <Results> with QXmlStreamReader, but how does this
      help. How can i write to a specific tag in an existing XML file without writing the complete XML fiel again?
      Can anyone give me a hint?
      Thx

      The XML looks like this and between the tags Data and Points a lot of other tags.

      <?xml version="1.0" encoding="utf-8" standalone="yes"?>
      <Calibration version="0.5">
      	<Sensor sn="" type="">
      		<BinFile></BinFile>
      		<Data>
      		</Data>
      		<Points>
      		</Points>
      		<Results>
      		</Results>
      	</Sensor>
      </Calibration>
      
      
      J Offline
      J Offline
      JonB
      wrote on 23 Mar 2023, 16:17 last edited by JonB
      #2

      @MECoder said in How to write specific tag in existing XML using QXmlStreamWriter ?:

      How can i write to a specific tag in an existing XML file without writing the complete XML fiel again?

      You can't update an actual XML text file (just like you can't for any text file). You have to rewrite the whole new XML over the whole file.

      1 Reply Last reply
      0

      1/2

      23 Mar 2023, 15:46

      • Login

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