06-14-2013 02:54 AM
Hallo all,
I'm having a strange error parsing XML files with labview. I have an XML file in one single line, without CR at end of each tag. A normal browser or XML parsing tool is capable to read it, but not with Labview.
The error I have is with "Get Next Non-Text Sibling.vi", which internally fails to read Type property (Error -2630, Property Node (arg 1) in NI_XML.lvlib:Get Next Non-Text Sibling.vi->XML Get Siblings Childs Nodes.vi->Encode data to label (Path).vi).
Labview XML parser works if I add a CR at each tag/node.
I'm quite sure this is a labview bug. A workaround I have found is to open the file, then save the file with Save File (Pretty Print) method and reopen it again, but it is time-consuming and I would like to avoid it.
Regards,
Daniele
Solved! Go to Solution.
06-15-2013 01:59 PM
The error indicates that no sibling exists, but without looking at your code it's difficult to figure out the problem.
Can you post your VI?
06-17-2013 01:33 AM
Here part of my parser, please note that the same XML with CR between ">" and "<" works like a charm.
Daniele
06-17-2013 03:07 AM
Which node do you pass to XML Get Siblings Child Nodes.vi ? That is also important.
I can imagine the following scenario causing your problem: Your input node has a child node C,, but this child node has no siblings. Get Next Non-Text Sibling.vi will fail in this case. If you put a <CR> at the right position in your XML you create a text node with content <CR>. If this text node is a sibling of child C then Get Next Non-Text Sibling.vi still won't return anything but no error should occur. IMHO this is expected behavior. You can however implement your own version of Get Next Non-Text Sibling.vi. Use the Next Sibling property and check if it returns a valid refnum.
06-17-2013 07:45 AM
You were right, I did my own Get Next Sibling taking care of text nodes (which includes also CR, I did not know it!).
Now it is working, there is no labview bug, also if XML functions documentation is very poor.
Thank you,
Daniele
06-17-2013 08:10 AM
Great to hear that it works! Regarding XML you should also consult non-LV-specific documentation. The tutorials at w3schools are great resources. Here is the DOM tutorial: http://www.w3schools.com/dom/default.asp .
Also note that the LVXML parser uses Xerces internally so if you encounter something really weird it can sometimes help to look at the Xerces documentation.
candidus