dalcanto Posted August 4, 2009 Report Share Posted August 4, 2009 Hallo, I'm an Italian Engineering student, working with LabVIEW for thesis work I'm facing big problems in the use of XML files. I have an application which generates XML files with clusters containing arrays and scalars according like in the example pasted below. My task is to read it and export the data in a human-friendly CSV document. Since I don't know the actual content of the cluster, I need some kind of intelligent vi which goes through the XML file looking for arrays and other data structures in order to export them properly in the CSV format (columns with headers). Thank you <Cluster> <Name></Name> <NumElts>3</NumElts> <Array> <Name></Name> <Dimsize>6</Dimsize> <I32> <Name></Name> <Val>0</Val> </I32> <I32> <Name></Name> <Val>1</Val> </I32> <I32> <Name></Name> <Val>2</Val> </I32> <I32> <Name></Name> <Val>3</Val> </I32> <I32> <Name></Name> <Val>4</Val> </I32> <I32> <Name></Name> <Val>5</Val> </I32> </Array> <DBL> <Name></Name> <Val>3.14159265358979</Val> </DBL> <String> <Name></Name> <Val>ciao</Val> </String> </Cluster> Quote Link to comment
Anders Björk Posted August 5, 2009 Report Share Posted August 5, 2009 Hello Do all files have exactly the same structure and number of data? Hallo, I'm an Italian Engineering student, working with LabVIEW for thesis work I'm facing big problems in the use of XML files. I have an application which generates XML files with clusters containing arrays and scalars according like in the example pasted below. My task is to read it and export the data in a human-friendly CSV document. Since I don't know the actual content of the cluster, I need some kind of intelligent vi which goes through the XML file looking for arrays and other data structures in order to export them properly in the CSV format (columns with headers). Thank you <Cluster> <Name></Name> <NumElts>3</NumElts> <Array> <Name></Name> <Dimsize>6</Dimsize> <I32> <Name></Name> <Val>0</Val> </I32> <I32> <Name></Name> <Val>1</Val> </I32> <I32> <Name></Name> <Val>2</Val> </I32> <I32> <Name></Name> <Val>3</Val> </I32> <I32> <Name></Name> <Val>4</Val> </I32> <I32> <Name></Name> <Val>5</Val> </I32> </Array> <DBL> <Name></Name> <Val>3.14159265358979</Val> </DBL> <String> <Name></Name> <Val>ciao</Val> </String> </Cluster> Quote Link to comment
dalcanto Posted August 5, 2009 Author Report Share Posted August 5, 2009 Hello Do all files have exactly the same structure and number of data? No, that's the problem, in other words I cannot use the unflatten function. Clusters may contains one or more arrays of different sizes, scalars of different types... Elements of the cluster are supposed to be its children, aren't they? Is it possible to access each of them from the children list of the cluster, see which is their type and implement different data extractor for 1D array, 2D array and scalars? Then write these data in a csv file should be the easier part. I think it's gonna be a mess, but there should be some way,no? I'm forwarding my vi draft with many comments and a couple of xml file samples. Thank you very much data structure.doc XMLData_example1.xml XMLData_example2.xml read_array.vi Quote Link to comment
Anders Björk Posted August 5, 2009 Report Share Posted August 5, 2009 No, that's the problem, in other words I cannot use the unflatten function. Clusters may contains one or more arrays of different sizes, scalars of different types... Elements of the cluster are supposed to be its children, aren't they? Is it possible to access each of them from the children list of the cluster, see which is their type and implement different data extractor for 1D array, 2D array and scalars? Then write these data in a csv file should be the easier part. I think it's gonna be a mess, but there should be some way,no? I'm forwarding my vi draft with many comments and a couple of xml file samples. Thank you very much You could use search and split vi in String palette and Addition string functions and work on the string by using them. Write up the common cases of clusters as a start. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.