LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Searching within an XML node

Solved!
Go to solution

I'm trying to use the XML parser inside LabVIEW to read a custom XML file.  Basically I have several SubTest tags, each of which may or may not contain several tags.  I want to search within each of these SubTest tags to see if it contains each of the tags I'm interested in and write it to a cluster if it exists or write a default value if it doesn't exist.

 

I'm trying to use Get All Matched Nodes and Get First Matched Node to accomplish this but it doesn't seem to work.

 

I use Get All Matched Nodes to search for SubTest tags and then pass each of these nodes into Get First Matched Node to search within the node for each of the several tags I'm interested in.

 

The problem is that Get First Matched Node returns the first match for the entire document each time, NOT the node I pass into it.

 

I've attached a simplified VI that illustrates the problem.  Is the documentation for Get First Matched Node wrong or am I doing something wrong?  Thanks.

 

Note: XML Help is saved in 2012 and XML Help_11 is saved for 2011

Download All
0 Kudos
Message 1 of 3
(4,077 Views)
Solution
Accepted by topic author Gollum

Your search for price is wrong.


As you already are given a link to the book node, then you don't need to search again from the top node.

Change your XPath 2 from "/bookstore/book/price" to only "price".

0 Kudos
Message 2 of 3
(4,061 Views)

Thank you. Funny thing is I had tried "/price" and "/book/price" but never thought to just try "price".  Thanks for the reply. 

0 Kudos
Message 3 of 3
(4,045 Views)