LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from an XML previously created by LabView

Solved!
Go to solution

Hi everyone,

 

My problem is, as the title says, I need to read Data from an XML file, if the file does not exist, LabView creates it. So far it works. After the creation though, when I go through the subroutine again and want to read the data back from the XML file, it brings me the Error Code 1006 and tells me something about not being able to read it since "the XML-Tag isn't the same type as the type of the variable connected." (roughly translated from German)

 

The Variable I want to read something back to is a Cluster consisting of 2 Clusters constisting of 1) two numeric elements and 2) a string and a 1-D array of 12 numeric element.

 

The part that's confusing me is, that LabView saved the data itself w/o problems and in its own XML format. So it shouldn't really bring up any problems reading it back to the same variable, now should it?

 

If anyone has an answer, I'm happy about anything, this has been driving me nuts the whole day Smiley Mad

 

Thanks in advance and Regards,

 

Pedro

0 Kudos
Message 1 of 7
(3,600 Views)

Can you post your vi or at least an image of where you write the xml file and where you try and read back? The error code is, I think 1106. It is not clear what you are using (LabVIEW creates it is pretty vague) nor how you are attempting to read it back ("go through the subroutine again"). What LabVIEW components are you using, and how are they connected?

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 2 of 7
(3,593 Views)

Hi,

 

sorry for my vague description, lets try to fix this:

 

For writing the XML-File, I use "Write To XML File.vi", the LabView standard XML writing VI.

For reading from it again, I use "Read From XML File.vi", also the LabView standard.

 

My LabView version is 8.5

 

I'll attach some pictures and the created XML file which I hope will be of help.

 

"Limits Template.png" is my Cluster to save the data in. As I said previously, the data was written from this very cluster, yet it cannot be read back to it. As you can see in there, the array is created correctly with 12 elements and their corresponding sizes.

 

Thanks in advance,

 

Regards,

 

Pedro

 

EDIT: checked again, the error code indeed is 1106

Download All
0 Kudos
Message 3 of 7
(3,575 Views)

I could imagine, that LV has a problem with this as it is strange letters... what was your initial input for this string?

 

 

<String>
<Name>GetVersionAnswer</Name>
<Val>�l������������������������������������PIC_V1R1.0.2��������������</Val>
</String>
Message 4 of 7
(3,567 Views)

Hi,

 

even when I create the XML file emtpy, that is the array initialized, but filled with 12 zeros and the string empty, the function isn't able to read it back.

 

The idea behind this whole XML-file dilemma is, that I want to have a configuration saved in this XML for different device-versions. So for each version I got a different answer-string for the keep-alive or I am expecting another SerialNo etc. At the start of the test program, I can read this info and later on compare it with the received values to determine whether the device is functional or not.

The file I uploaded here was already created with a configuration, but as I said, the ones w/o filling are not readable either.

 

Any other ideas?

 

Regards,

 

Pedro

0 Kudos
Message 5 of 7
(3,565 Views)

Hm, thats a rather strange behaviour. Are there also the symbols in the empty cluster? Maybe it might help to check for non displayable characters.

Please try what happens, if you do: "flatten to XML.vi" and directly wire it back to "unflatten from XML.vi". For the unflatten part wire your cluster to the "type" connector. As you have the same (cluster) type for all apperatus this should always work. Maybe just save the flattened string and use these two functions if thats working?

Message 6 of 7
(3,553 Views)
Solution
Accepted by topic author Pedro89

My fellow LabViewers, the problem is solved.

 

It seems to have been an issue with different datatypes which I did not see, as the datatype in my cluster in the write routine was different from the one in the read routine.

 

a thousand thanks for your help, I would not have had the patience to look through this code thoroughly one more time if it weren't for your efforts.

 

Have a nice day an Kudos to you all!

 

Regards,

 

Pedro

Message 7 of 7
(3,550 Views)