03-28-2011 03:24 PM
say, I have an XML file such as this one:
<?xml version="1.0"?>
<pdml version="0" creator="me">
<packet>
<proto name = "geninfo" showname="General Info">
<field name = "num" value="1" />
<field name = "len" value="5" />
</proto>
<proto name = "data" showname="myData">
<field name = "data" value="00:0A:0B:0C:0D:0F" />
</proto>
</packet>
<packet>
<proto name = "geninfo" showname="General Info">
<field name = "num" value="2" />
<field name = "len" value="4" />
</proto>
<proto name = "data" showname="myData">
<field name = "data" value="EF:AA:FB:0C:0D" />
</proto>
</packet>
As you can see, I have two packets. I was able to get Labview to read in a child node array of two but now how do I read in the attribute as an array or collection of record for each "proto" and then obtain the data only. For example, I would like to retrieve data from packet #2 and it should yield "EF:AA:FB:0C:0D", how do I do this? I know how to retrieve a simple xml file but getting to the attribute part is a little tricky here. Thanks
Solved! Go to Solution.
03-28-2011 03:47 PM - edited 03-28-2011 03:48 PM
Not sure exactly how you want to get to the data, but XPath makes it relatively straightforward, just use '@name' to specify an attribute.
Here you specify the packet number, you could drop the [number] and use Find All Matched Nodes to get an array for all packets as well.
03-28-2011 04:05 PM
Where can I get that XPath VI, the one with the search icon? Is this part of LV 8.6 also?
03-28-2011 04:25 PM
D'Oh! That one is new for LV9. Sorry. Here is a variation using .NET (next you'll tell me you are on a Mac).