LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

transfer tree control to subprogram as XML

Hi Pericles,

 

I think I understand what you want to do.  I couldn't resist revising my code to work with the TestConfiguration.xml file.  Give this a try.  You'll have to enforce some tree editing rules - you can't have spaces in the xml parameter names if you want to be able to read the xml with other programs like web browsers.  Otherwise it seems pretty straight forward.  Give it a try and let me know what you think.

 

thanks,

George

0 Kudos
Message 11 of 23
(1,463 Views)

Hi George,

I have treid your VI - it seems to work though there is still a parsing error Line 5, Column 2,  Message: Expected an element name when the XML string is converted to file Line 5 is the line wher #comment appears - I will try a file witout comment at first. Maybe  it will be enought to add a usual XML first line - it shall be one with encoding (this is not in the TREE). I'll add the line (tomorrow - it is rather late today 🙂 and will go thru your  in order to understand how you did it. I'm pretty sure that it will be OK.

Thank you very much for your help, I'll write you tomorrow about the final results

Best regards

0 Kudos
Message 12 of 23
(1,457 Views)

Hi George (once more - couldn't let it be without trying again)!

I took a small XML file without comments and it works correctly, no parsing error. It means, that you don't expect comments in your XML string. The tree structure, which you generate differs from mine: in my structure I write on the left side (Column 0) all nodes, in column1 - only attributes. You write in the column 2 attribute names and values with "=". When I take a larger file, which I have to use normally, your presentation of the xml string into a tree is not correct: you go strait forward and bind every followin node as a child. In reality there are a lot of siblings - nodes, which are placed "in parallel".

Tomorrow I look at your code in detail.

Good night!

0 Kudos
Message 13 of 23
(1,452 Views)

Hi Pericles,

The new version of my code writes the element names in column 0 and the data in column 1.  I saw the same problem with the # character in the element name.  Take a look at this: http://www.xml.com/pub/a/2001/07/25/namingparts.html.  The element name options are pretty limited.  If you have anything other than the allowed characters, you will get a parsing error.  If you have to have the # character, you'll need to translate it to the allowed set of characters - maybe something like __pound__ .  Then translate it back to # when you put it in the tree.

thanks,

George

Message 14 of 23
(1,448 Views)

Hi, George!

Prinicipally it works - I took files with more complicated structure than in your example , converted them to tree with my VI and then converted result tree with your VI to a string and a file (it is obviously a good method to do it this way). After that I displayed them with my XML display and with a professional one (XML notepad 2007). THe structure is kept, the difference is only in the last node, how to present it - you do it as a text node, I did it in another way, but I think I can fit this last step to my presentation. I think it would be less work than to write it node by node from the tree into an XML document.

Thank you very much for help!

0 Kudos
Message 15 of 23
(1,439 Views)

Dear Goerge, 

I want to use your function to exchange the data within the tree. So my idea is I transfer tree into xml and then programmatically i will change the text of the xml file and then i will transfer the xml to tree again. I am 3 months old in the Labview so i am not good at refnum. I am attaching my VI. guide for doing this. My VI contain tree and your function but i am not aware about how to connect them. thanks in advance

 

Yagnik

0 Kudos
Message 16 of 23
(1,262 Views)

Hi Yagnik,

 

Take a look at the code posted on June 4, 2014 in this thread.  Its an updated version and there is an example program that shows how to hook up the control references.  To get a control reference for your table, just right click on its icon in the block diagram and select  Create>>Reference.  You can pass the reference value to any number of VIs, as the example shows.  Just wire it up like anything else.

 

Once you get the hang of it, you will probably want to write some code to edit individual items in the tree.  You have a lot of data in the tree and this code takes a long time to write the entire tree.

 

George

Message 17 of 23
(1,253 Views)

thanks a lot for the reply. 🙂

 

Now using your ExampleRead_Testconfiguration, I tried to write my tree to xml (Using TREE to XML) and then xml to tree (Using XML to TREE) but your function doesnt give the same tree again. I didnt made any change in the xml text still it doesnt give me back the same tree. I am attaching the VI. I found the Problem and its Syntax Problem (My Tree has a '<nothing>' in the value column and xml also has the same '<>', I am attaching the Image to make you understand). Can you help me for this special case? I want to your function XML to TREE just neglect '<nothing>'. 

 

Thanks in Advance

0 Kudos
Message 18 of 23
(1,247 Views)

I got the solution. I made modification in your function VI and remove the '<>' with '()' because anyways its temporary text in my case and I am not going to use xml text any other place. Dhanyavad George 🙂 (Thanks a lot in Hindi(Indian))  for making this Function VI. As I am using it in other way then your original concept but working for me perfectly as changing the tree according to requirement. 

0 Kudos
Message 19 of 23
(1,242 Views)

I think the blank tree was caused by your use of a local variable to read the XML data OUT.  Since you did not explicitly control when the variable was read, it can be read before the indicator is populated with data.  It would be safer to do it this way:

noLocalVariable.png

 

With this fixed, I see that the XML parsing is messed up by the <> characters in the data string.  Replacing them with () sounds like a good idea.   By the way, running this vi repeatedly makes a mess of the tree - it would be better to output to a new tree for debugging.  Anyway, Looking back at my code, I should have used escape characters when converting the tree values to XML and then unescaped them when converting back to the tree.  I found functions from NI that worked well.  Check out the attached zip.  It works with <> characters in the tree now.

 

Message 20 of 23
(1,223 Views)