LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I affix Data to a existing XML file?

Hallo.
 
I have to write Data to an XML file. This I have to in a stacked Sequence within a while loop. How can I write my Data to my existing XML file without overwriting my existing Data from the loop before?
 
Thanks
 
0 Kudos
Message 1 of 6
(3,522 Views)
Before your loop, position the file pointer to where you want to start writing data.  Inside the loop, do not specify the file position (leave the position inputs unwired).  LabVIEW will automatically and efficiently increment the file pointer for you.
0 Kudos
Message 2 of 6
(3,510 Views)

Hi DFGray.

Thank you for your answer. I think I use another XML-VI such as you use.

Would it be possible, that you send me a little example code to see exactly what you mean?

Thanks

0 Kudos
Message 3 of 6
(3,503 Views)
You can take XML and convert it to a tree structure using the MSXML parser, then you can add a node to the exact location of teh XML file, so you can modify arbitrary areas of the XML structure efficiently, then save the changed XML structure back to file.  There is also LABXML form openG.org but I have only used the activeX XML object parser from Microsoft.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 6
(3,493 Views)
I made the erroneous assumption that you were using your own XML creation code.  The LabVIEW write to XML file VI overwrites the file every time.  You can get around this behavior in  a couple of ways.
  1. Create your own write to XML VIs using the LabVIEW one as your base.  The LabVIEW one write a header, writes your data, then writes the end tag.  Split this up so that you open the file and write the header before your loop.  During the loop, write your data.  Write the end tag and close the file when you exit the loop.  Don't overwrite the LabVIEW vi.lib function, or you will probably regret it.  Copy it to a different location before you start your modifications.
  2. Use the LabVIEW write to XML file for the first write of the loop.  This will give you a file with a header and your first set of data.  Still in the first loop iteration, reopen the file and position the file pointer on the start of the end tag (</LVData>).  In subsequent loop operations, flatten your data to XML and write to the file directly using the file write primitive.  When you exit your loop, write an end-of-line character and the end tag "</LVData>" and close the file.
If you need more detailed help on either of the above methods, let me know.

Out of curiosity, why are you saving your data as XML?  There may be a better way to do it, depending on your application.
0 Kudos
Message 5 of 6
(3,479 Views)

Hi!

Can anyone post an example of how to convert a XML-Document into a tree structure by using the MSXML Parser. I tried, but without success.

Thanks for your answers!

Steve

0 Kudos
Message 6 of 6
(3,451 Views)