LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XML string to Variant

Hi everybody,

I would like to save control values into a database and be able to restore them from it. But I can't set a variant control from an XML string.

This works with flattened string.

Do I make something wrong or is it impossible ?
0 Kudos
Message 1 of 5
(4,432 Views)
In LabVIEW 6.1 it is possible to flatten variants to XML. However, Unflatten From XML is not able to convert XML data back into a variant. The primitive will accept the XML code, but the variant output will be empty. The reason variants are accepted at all, even though they are not unflattened, is to allow datatypes such as clusters which contain a variant to still be unflattened(although the variant data will be lost) without returning an error.

You may want to consider using the LabVIEW Database Connectivity Toolset. This is an add-on package for LabVIEW which will allow you to write information to a database variant, and bring that stored information back into LabVIEW data.
0 Kudos
Message 2 of 5
(4,432 Views)

Has this behavior changed since 6.1?  I am assuming not as I am attempting to do the same thing in 8.2 and am receiving no error, but void data.  What is the recommended way for storing variable type data in XML format?

Dan Marlow

0 Kudos
Message 3 of 5
(4,201 Views)
Hi,

Here are some other discussion forum posts that I think will be useful to you:
Unflatten xml data
Unflatten xml data type

Let me know if these help!
Amanda Howard
Americas Services and Support Recruiting Manager
National Instruments
0 Kudos
Message 4 of 5
(4,182 Views)

Hello,

 

One workaround for this that is working for me is to use Variant To Flattened String, put the two outputs from that into the XML, and then unflatten out of the XML.  Allows you to store arbitrary datatypes in XML.  I've attached an example screenshot.

 

Andy

Message 5 of 5
(3,890 Views)