From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

xml to cluster (by name instead of by structure)

Hello everybody!

 

I saving data from labview to a xml file by using the built in 'unflatten from XML' vi and it works good. If I use the 'Flatten from XML' to parse my XML to a cluster it works if it is exactly the same structure of the cluster that was used to generate the XML file.

 

If we got this example:

Cluster used to generate the xml file

Name<String>

Year<timestamp>

Description<String>

ID<DBL>

 

I want to be able to put data from the xml file to these kind of clusters to

 

Name<String>

ID<DBL>

 

and

 

Name<String>

Year<timestamp>

Description<String>

Long Description<String>

ID<DBL>

 

and leave the variable(s) in the cluster empty if corresponding field/node in the xml file does not exist. And if the order/structure of the cluster don't match the xml file find the variables by name instead of by structure. Any idée how to do this?

 

 

 

Message 1 of 5
(6,177 Views)

Hi,

 

You can make your own vi for parsing the XML files.

 

For example, you have in your VI a Cluster, Read all the elements of the cluster using their Name and search in the Output String from XML File Read VI for your element. Between <Name> </Name> you can search for Control name and <Value> </Value> for the value stored by the control or element.

 

In the attachment is a sketch that works for simple clusters. You can expand it for your needs.

 

This solution is ok for small and simple clusters. Otherwise everything become too complicated.

 

Hope it helps.

 

Paul

0 Kudos
Message 2 of 5
(6,170 Views)

Here's the easy way:

 

jki.net/easyxml

 

Disclaimer: This is a commercial product, and I'm on the team who helped create it 🙂

0 Kudos
Message 3 of 5
(6,149 Views)

Hi,

 

Can you please post your example vi? My German is poor so it is difficult to understand which properties to use.

 

Best wishes.

0 Kudos
Message 4 of 5
(6,129 Views)

Hi Tudor,

 

Sorry, I didn't notice thatSmiley Happy.

 

I've modified a little bit the VI to make it more friendly. Please see attachment.  Let me know if something is not clear.

 

Rgds,

Paul

0 Kudos
Message 5 of 5
(6,125 Views)