Example Code

Read LabVIEW Class Data from an XML File

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
This VI reads class data from an XML file and populates an object with that class data.


Description

Class data that has been stored on disk as an XML file can be brought back into LabVIEW using the XML read function. This example demonstrates how the XML file is read and the data from the file is populated into an existing object. Note that the data from an XML file can only be populated back into the same class that was used to write it to disk.


Requirements

  • LabVIEW 2013 (or compatible)


Steps to Implement or Execute Code

  1. Download unFlatten_XML_to_Class_LV13.zip
  2. Open unflatten_class_to_XMLe.vi
  3. Run the VI.

 

Additional Information or References
VI Block Diagram

 

 1.png

 **This document has been updated to meet the current required format for the NI Code Exchange.**

 

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
wireman
Member
Member
on

This is terrific as far as it goes. It seems that this will let you add new elements to the class object cluster (say numeric 2) and still unflatten from an old XML string of the class into the object. However, the code has no way of knowing whether or not the XML had a field specifying what numeric2 was. The numeric2 comes out as 0 (presumably because that is the default value of a numeric) because it was not in the XML.

So, it's great we can do this, but it would be nice if NI provided a way for us to retain object values input to the Unflatten from XML if they are not defined in the XML string (so that we can specify default values for new controls in the class object).