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 ?

How to write specific tag in existing XML using QXmlStreamWriter ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 156 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 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>
    
    
    JonBJ 1 Reply Last reply
    0
    • M MECoder

      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>
      
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on 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

      • Login

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