LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

xml headaches

My associate put a lot of work and effort into creating a very necessary UI for saving and retrieving configuration data for different DUTs we test using XML. However, if I make one change to a cluster the entire file XML file is useless. If I eliminate the change the file is OK again. Is this for real? Is XML this difficult to work with? I really don't want to refactor this part of our code into OpenG config file methods if I don't have to.

PaulG.

LabVIEW versions 5.0 - 2023

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 1 of 7
(2,848 Views)

It sounds like you are using the Read From XML File and Write to XML File VIs. These VIs generate XML files that use the LabVIEW schema. If you change the cluster then the XML format must match. Otherwise the functions won't be able to parse the file. Thus, if you change the cluster, but not the XML file, the function will throw an error since the data structure does not match the structure of the XML file. This is not an issue with XML files, but rather with the way the functions work. Convenience comes at a cost.

 

A more flexible solution is to use your own XML schema. You'd need to write your own parsing functions (i.e., what the Read From XML File does internally). However, this isn't as hard as it may sound. LabVIEW comes with the XML Parser functions, which are used to read/write generic XML files. An alternative is to use toolkits like LabXML or JKI's Easy XML (Google/Bing/Yahoo/whatever them).

0 Kudos
Message 2 of 7
(2,837 Views)

No, we are reading and writing xml as a text file and using flatten/unflatten XML. 

PaulG.

LabVIEW versions 5.0 - 2023

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 3 of 7
(2,828 Views)

Same thing. Those also use the LabVIEW schema. Please check the documentation, as this is explained in there.

0 Kudos
Message 4 of 7
(2,824 Views)

This is the major drawback to the XML and is incredibly frustrating. I usually hold my XML code in a dedicated functional global. This functional global has 4 cases: Load, Get, Set, and Save. Whenever I want to change the XML, I open the functional global, load the file, make current values default. Then, I open my typedef cluster add the new element (i.e. control). Then, I go back to my functional global and set, then save. Headache, but it works. The only problem is when you forget to load and make current values default first Smiley Mad

 

 

Message 5 of 7
(2,809 Views)

Create a class from the cluster. If you flatten an object to XML you can still unflatten it even after modifying the class data members. A class is nothing but a cluster that only VIs which are part of the class have permission to access.

 

Just be careful not to reset the mutation history or you will not be able to unflatten your older objects. One way of unintentionally reseting the mutation history is to move the class into or out of a library. That makes it a different class and the mutation history is reset to 1.0.0.

=====================
LabVIEW 2012


Message 6 of 7
(2,795 Views)

I have used the XML parser in labview to make my own schema with great suscess.  However writing and designing the schema requires some thought and implementation took several hours for a relativly complex cluster (contained an array of classes and each class implemented toXML and fromXML functions).  In the long reu I was very happy with the code since the clusters and classes evolved throughout the project but my configuration files did not break (why I didnt ues the labview schema).

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 7 of 7
(2,775 Views)