LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

unflatten from xml on class in lvlib

I am using Flatten To XML and Unflatten From XML on a class in LV2009.  This works fine until I put the class in a lvlib.  Then the Unflatten From XML returns an error 1527: Attempted to read flattened data of a LabVIEW class that is not currently loaded into LabVIEW.  In my test case the flatten and unflatten are in the same VI, so the class was there when it was flattened.

 

Any help is appreciated.

0 Kudos
Message 1 of 6
(3,260 Views)
I reproduced this in LabVIEW 2009. I have filed CAR# 193210 to R&D for further investigation.
Jarrod S.
National Instruments
0 Kudos
Message 2 of 6
(3,245 Views)

I don't know of a good workaround at this time if the class has to be inside a LabVIEW library. I tried a few things that I hoped would work that didn't:

 

  • Bundling the class into a single-element cluster before flattening to XML, then unflattening and unbundling.
  • Inserting the class into a Variant before flattening. Then unflatten as a variant and do Variant to Data. This would have added a <LVVariant> tag to the XML, but otherwise would have been harmless.
  • Trying the same with a single-element array of the class.


None of those worked. The best workarounds I have for you if the class is inside a library are:

 

  • Manually serialize and unserialize the class contents to XML using LabVIEW's XML Dom parser. This is a decent amount of work, and won't work with other XML files you create using LabVIEW's default schema.
  • Flatten the class to string using Flatten to String. Then wire the string into the Flatten to XML. To get the data out, Unflatten from XML as a string, then Unflatten from String into your class. The XML text isn't pretty or really representative of the data stored in it, but hey, it at least saves and loads the data.
Jarrod S.
National Instruments
0 Kudos
Message 3 of 6
(3,241 Views)

Hi,

 

I have similar problem when reading class data from a file. If I put class in a labview library, I get an error "Attempted to read flattened data of a LabVIEW class that is not currently loaded into LabVIEW", but if class is not in the labview library everything works just fine.

I have Labview 2010.

Any help would be appreciated.

 

Thanks,

Andrej

0 Kudos
Message 4 of 6
(2,843 Views)

Hi andrej,

 

If you post your code, I will attempt to recreate your issue and try to find a work around.

 

Thanks,

 

Matt J

Matt J - NI Tools Network
0 Kudos
Message 5 of 6
(2,822 Views)

Hi Matt-J,

 

I solved the problem. I created an file (data type was class) with write binary, when a class was not in a library yet. Then I was trying to read the file after I put the class into library. When I created the file with class in library the problem was gone.

Thanks anyway.

 

Regards,

Andrej

0 Kudos
Message 6 of 6
(2,808 Views)