09-14-2014 07:30 AM
Hi, Here is my xml doc.
<?xml version="1.0" encoding="utf-8" ?>
<Cable>
<Product>
<Type>FA</Type>
<Start>1800</Start>
<Stop>2015</Stop>
<Mark>1952.5</Mark>
</Product>
<Product>
<Type>FAD</Type>
<Desp>2.6G</Desp>
<Start>1880</Start>
<Stop>2635</Stop>
<Mark>2635</Mark>
</Product>
</Cable>
I want to use "get the first matched node" vi to locate "FA" node. The I use "Get node text content" vi to get the value "1800". and I also want to get next two node value 2015 and "1952.5". But my VI is not working. I past my vi diagram here. could someone take some time to look at it? Thanks!
Solved! Go to Solution.
09-14-2014 10:23 AM - edited 09-14-2014 10:24 AM
"not working" as in what?
getting different values?
And stop with posting pictures.
A real VI of your work what you need to attach.
09-14-2014 12:06 PM
song403 a écrit :
Hi, Here is my xml doc.
<?xml version="1.0" encoding="utf-8" ?>
<Cable>
<Product>
<Type>FA</Type>
<Start>1800</Start>
<Stop>2015</Stop>
<Mark>1952.5</Mark>
</Product>
<Product>
<Type>FAD</Type>
<Desp>2.6G</Desp>
<Start>1880</Start>
<Stop>2635</Stop>
<Mark>2635</Mark>
</Product>
</Cable>
I want to use "get the first matched node" vi to locate "FA" node. The I use "Get node text content" vi to get the value "1800". and I also want to get next two node value 2015 and "1952.5". But my VI is not working. I past my vi diagram here. could someone take some time to look at it? Thanks!
First, there is an empty space in front of <?xml version="1.0" encoding="utf-8" ?> that will make the XML parser generate an error.
From what you showed us we cannot know what xpath expression you used with the Match First Node.vi function. FA is already a text node so to match it you should use an xpath expression like //Type[text() = "FA"], this will return a reference to the FA text node. Then you can use this reference with the Get Next Non-Text Sibling to get a ref to the Start node. Continue like this for the Stop and Marker Nodes.
One last advice, close the references that you opened.
Ben64
09-14-2014 10:28 PM
Hi,
Thanks! I think that your suggestion is correct. But I write my VI according to your instruction. But it is unable to fetch correct value. Could you please check it.
09-14-2014 10:29 PM
my vi!
09-15-2014 06:33 AM
09-16-2014 08:45 AM
yes. I forget //. Thanks!