LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error in Get Next Non-Text Sibling for XML without CR at end of tag

Solved!
Go to solution

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

0 Kudos
Message 1 of 6
(3,294 Views)

 

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?

 

0 Kudos
Message 2 of 6
(3,267 Views)

Here part of my parser, please note that the same XML with CR between ">" and "<" works like a charm.

 

Daniele

 

0 Kudos
Message 3 of 6
(3,253 Views)

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.

0 Kudos
Message 4 of 6
(3,244 Views)
Solution
Accepted by topic author dirida

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

 

0 Kudos
Message 5 of 6
(3,234 Views)

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

 

0 Kudos
Message 6 of 6
(3,227 Views)