LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Node refnum comparison (XML parser)

Hello,

 

I am trying to parse an XML document (actually an Open Office doc) with the LabVIEW 2009 built-in XML Parser. My problem is to identify if two Nodes are actually refering to the same point in the XML or not. For example:

I do a search for specific table cells. The result is an array of Nodes. I want to know if they are on the same table row. So I go up to the first "table row" parent, of which I get the reference. Now I would like to compare two of these parent "row" references, to check if they refer to the same table row. Use of the "equal" LabVIEW function seems not to work (always pretends the reference is different, even if pointing to the same table row actually).

 

Any idea ?

 

Vincent

0 Kudos
Message 1 of 3
(3,157 Views)

Hello Vincent,

 

thank you for posting at the National Instruments forum. Unfortunately, I do not have Open Office installed on my computer. Could you please provide a simple sample document (and VI), which clarifies the behaviour?

 

Best regards

Marian Vorderer
0 Kudos
Message 2 of 3
(3,124 Views)

Hello,

 

Thank you for your interest for the topic. Here is a small example, which is described here:

 

Assume you have an XML with following content:


<XML>

<Parent>

     <Child name="A1">

          <Feature />

     </Child>

     <Child name="A2">

          <NoFeature />

     </Child>

</Parent>

<Parent>

     <Child name="B1">

          <Feature />

     </Child>

     <Child name="B2">

          <NoFeature />

     </Child>

</Parent>

</XML>


Let's say I need to find all the <Feature> nodes and check whether or not they belong to the same <Parent>. If I look for all the <Feature> nodes by sequentially parsing the whole XML (with a combination of "Next Sibling" and "Next Child" navigation), I will certainly know when I switch from one <Parent> instance to the other one, but this is very inefficient for large XML. I have chosen to use the following method instead:

 

- with the "Get Elements by Tag Name Array" method for the XML document (DUXGetElementsByTagName), I get an array of all the <Feature> nodes in the document. These are node references to <Child name="A1"/> and <Child name="B2"/> in the above example.

- from both of these nodes I go up to successive parents until I find the <Parent> node reference.

- now I have two different references to <Parent> nodes. I am almost over, I just need to check whether these are the same <Parent> node, or if they are different instances of a <Parent> node (as it is the case in the above example).

 

How can I do this last step ? Comparing the node references directly with the general "Equal?" built-in LabVIEW function does not work (result is always FALSE, even if both node references point to the same node instance). What is missing here is a sort of "IsSameNode" method, with two node references as inputs, and a boolean as output, that would just return TRUE if both references are pointing to the same node in the XML...

 

Hope this helps.

 

Best regards,

 

Vincent

0 Kudos
Message 3 of 3
(3,114 Views)