Converting LabVIEW data to XML formats the data so that when you save the data to a file, you easily can identify the value(s), name(s), and type of the data from the tags that describe the data.

For example, if you convert an array of temperature values to XML and save that data to a text file, you easily can identify the temperature values by locating the Value tag that identifies each temperature.

To convert a LabVIEW data type to XML format, use the Flatten To XML function. For example, the block diagram does the following:

  • Generates 100 simulated temperatures
  • Plots the array of temperatures to a chart
  • Converts the array of numbers to the XML format
  • Writes the XML data to the temperatures.xml file
LabVIEW block diagram for converting temperature data to XML and saving to a file.

To convert a data type in the XML format into LabVIEW data, use the Unflatten From XML function. For example, the block diagram does the following:

  • Reads the 100 temperatures in the temperatures.xml file
  • Plots the array of temperatures to a chart
Block diagram for reading and plotting temperature data from XML to LabVIEW data.
Note Although you can flatten and unflatten LabVIEW variant data to and from XML, LabVIEW returns an error if the variant data is an element of a cluster or is an array of variants.

LabVIEW XML Schema

LabVIEW converts data to an established XML schema. Currently, you cannot create customized schemas, and you cannot control how LabVIEW tags each piece of data. Also, you cannot convert entire VIs or functions to XML.

The predefined XML schema that LabVIEW uses is LVXMLSchema.xsd, which is located in the labview\vi.lib\Utility directory. You can open the file in a text editor to read the schema.

LabVIEW XML Examples

For examples of converting to and from the XML format, refer to labview\examples\File IO\XML\Flatten and Unflatten XML\Flatten and Unflatten XML.lvproj.