Published April 15, 2013
The latest addition to the MGI Library is MGI RobustXML, an alternative to using MGI’s popular Read/Write Anything VI’s for configuration or data files. Although RobustXML can be slower than Read/Write Anything, it provides one key advancement: the combination of human readability of LabVIEW Class data with Read/Write Anything’s level of forward/backward compatibility and convenience.
In the bad old days, if you had a configuration cluster that you wanted to serialize, your best option was to use the Configuration File VI’s to create custom VI’s for writing and reading. Each time you updated your cluster, you needed to make corresponding updates to your writer and reader.
A big improvement came with the OpenG Variant Configuration File VI’s which could automatically convert a cluster to/from a configuration file section. MGI’s version, the Read/Write Anything VI’s, massively increased the speed of reading and writing, making a tool usable for moderately large data, not just small configuration data.
Although Read/Write Anything can be used with just about any sort of data, some data, including LabVIEW class data, is simply encoded as hexadecimal and is therefore not human readable. If you want your class data to be human readable, the best currently available choice is to use the Flatten to XML function. However, if you use the Unflatten from XML function by itself you can quickly run into brittleness issues. If you attempt to unflatten cluster or enumerator data that is outside of a class and the cluster or enumerator elements have changed between writing and reading the file, Unflatten from XML will throw an error and you’ll get nothing.
Since changing cluster and enumerator elements are some of the most common modifications to make to a configuration cluster, MGI has created RobustXML. To the user, there’s only one VI to incorporate: MGI RobustXML Prepare to Unflatten. Optimally it’s used when an Unflatten from XML function has thrown an error. It massages the XML text in preparation for another attempt at Unflatten from XML. Since the massage can take about ten times longer than the attempt, you don’t want to apply it until after a problem has been found. RobustXML includes merge VI’s that drop that logic into your block diagram.
It’s good to have an alternative to Read/Write Anything for those cases where human readability of LabVIEW class data is important, but be sure to look at the VI help for a few more subtleties not mentioned here. (MGI RobustXML can be downloaded from the NI LabVIEW Tools Network via VI Package Manager)