There is a flat array structure that the tree control uses. The advantage of using this format is that there is no conversion required. We use this flat structure because updates on very large trees (+2000 elements) is very slow when updating via the native methods. Updates on the array are very fast and then you simply write the entire array to the tree control.
How do you get access to this flattened structure?
Unfortunately there is no way to read it from the tree. You can only set it. You can build the array of clusters your self and set the tree to that value. Use the invoke node with the method "Add multiple items to end". We created a LVOOP tree class and we maintain the data in both the tree and the flattened structure. Changing the value of the tree is accomplished by emptying the tree and then pushing the updataed flattened structure to it.
I'm looking for the solution for writing back a tree structure into XML file. I made a VI to present an XML-file as a tree, but it seems to me rather complicated to write it back. Perhaps I haven't yet a propert algorithm to do it. I was very glad to find your VIs and treid them, but:
- obviosly you use another form of a tree (my tree has another RefType, though they look the same - I converted my by means of "cast")
- the result wasn't a real XML file - as least not as LV "load" functon it "understands
Please have a look at my XML -file, its presentation as tree done by my VI and your result string - you will see, that in your strin are much more special information as it should be in an XML -file. If you have some ideas how to solve this problem (converting tree into XML string/file) I would be very thankfull to you - just now I have no more ideas how to do it .-(.
Please find attached 2 pictures of tree presentation and the original XML file
What type of tree are you using? I built this with the labview tree. Are you using .net or activeX? I wrote this with labview 7, so maybe its just out of date?
What error do you get from the xml load.vi? I wonder if my xml file is just missing some header information. Take a look at the example for the load.vi, it has an XML example file "TestConfiguration.xml" that starts with some encoding information. You could try copy/pasting that into your xml file to see if the load.vi will work correctly.
I'm not sure what you mean by "much more special information". Do you mean it is recording too many columns? In the labview tree there is a property "NumCols" that reports the number of visible columns. If all your information is shown in visible columns, then you could use this property to limit the number of columns encoded in the xml file. If you have some code to share, I'd be happy to take a look at it.
thank you for your answer. I use LabView tree and work with LabView 2013, maybe the tree itself is not uptodate, but after casting it works, I suppose, that it is just the XML string which you expect to get. I made an XML -display VI using LabView tools from the corresponding library - they are going from node to node getting names and attributes. As a result a tree with 2 columns is displayed. I can send you this VI to have a look at it.
I found and loaded TestConfiguration.xml, it can be also displayed with my VI, though it uses XSD - my original file doesn't have any XSD, that#s why it may be differen in your solution and in what I have to do.
I took my tree, "casted" it to your ref and than used "LoadXML" from the XML palett of LabView. I got the parsing error "Line 2, Column 2, Message: Expected an element name", maybe that means, that some header info is not correct.
As I see from you VI you convert the tree to an XML- string, and then you can save this string in a file, right? I thought of creating an XML -structure with nodes and attributes just from the tree, but obviously it is a very complicated way, isn't it? My problem is to save changes, which a user has done editing the Tree - it seems to be the simplest way to write donw the TREE completely in an XML file, because the tree has all the info. But maybe this way can#t be gone at all :-(.
Please find attached the VI to display an XML file in a tree with 2 columns. I used this display form as an XML Notepad 2007 does it.