LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XML vs Bytestream which is best?

I am looking for a flexible file format for my preference and other data files in my program. I have been using Bytestream format since it is simple to program. It is somewhat flexible with changing formats. For example, if I store a file as a cluster, but then change the cluster in the program to add more elements to the end of it, then I read in the file into the new larger cluster, it will read it in to the first part of the cluster like it should and give me an error denoting that the size wasn't what is expected. This is fine, but limits additions to the end of the cluster.


I tried using XML to get more flexibility hoping that I would be able to make changes to the middle of the cluster and the xml file format with its names a
nd such would be able to handle the changed cluster, but I was dismayed that the "Unflatten to XML" function does not work if the cluster is at all different than what is on the disk. It doesn't even fill in the existing fields!

Is there another solution someone else has found?

-Kirk
0 Kudos
Message 1 of 4
(2,696 Views)
I am not sure what you are putting in these files, how often, and what type of spped you need.

Lacking that I will through out two ideas.

1) INI files - Will handle additional fields just fine. If you try to a new filed from an old file, the INI file VI's will flag an error to help ID the missing fields. Default values can also be specified if the filed is not found.

2) Self-idenitfying datalog files - Use a cluster that has two fields. A numeric and a string. Use the numeric to ID the format of the file. THe string will hold a flattened cluster who's structure is ID'd by the numeric. Use the numeric to choose the correct cluster to do the "unflatten".


I hope this helps,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 4
(2,696 Views)
I am putting all sorts of control values in the files as the project grows. Additional clusters, individual scalar values, etc.

1) I tried INI files the problem with that is it doesn;t take clusters as an input to the Write Key function thus I have to continually modify the program that writes them to the disk whenever the cluster changes.
I kind of want it to automatically write the keys for me similar to what the flatten to XML function does.

And then read the keys back using defaults if the key doesn't exist.

2) doesn't really address my problem, I may have not been clear enough. What I would really like is to have access to the source of the unflatten to from xml function then I could just fix it to fill out the portions of the cluster that i
t can given the input xml, and not just abort and do nothing.
0 Kudos
Message 3 of 4
(2,696 Views)
Hi Kirk,

NOw that I know that, let me suggest you check out OpenG

http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RNAME=ViewQuestion&HOID=506500000008000000AF510000&ECategory=LabVIEW.LabVIEW+General

Jean-Pierre has developed a set of functions that will probaly serve as a good starting point for you. His functions automatically adapt to the controls and indicators and handles clusters, nested clusters, Cluster on tab controls, clusters in cluster in tab controls in other tab controls, arrays.... EVERYTHING!

I believe they only ask that if you make an improvement that you share the upgrade with the world.

Trying to help,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 4
(2,696 Views)