04-13-2011 07:55 AM
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?
04-13-2011 08:25 AM - edited 04-13-2011 08:26 AM
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
04-13-2011 11:53 AM
Here's the easy way:
Disclaimer: This is a commercial product, and I'm on the team who helped create it 🙂
04-14-2011 02:00 AM
Hi,
Can you please post your example vi? My German is poor so it is difficult to understand which properties to use.
Best wishes.
04-14-2011 02:19 AM
Hi Tudor,
Sorry, I didn't notice that.
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