05-23-2012 02:32 AM
Hello.
I've got some problems with extracting an array of elements (nodes) from a non-labview XML file. It does return an array containing the right elements, but I also get a lot of dummy-elements, which contains no data at all.
If I extract all the child nodes of an element by using the 'ChildNodesArray' property on an element which have got n child nodes, I ought to get an n-length array. Instead I get a (n*2)+1-length array, where the first and then every other element is an empty Text_Node and the interleaved elements are Element_Nodes containing the data of the actual child nodes. So for a node with 3 children it ends up something like this:
<node>
<child>value1</child>
<nextchild>value2</nextchild>
<nextchild>value3</nextchild>
</node>
is converted to the array:
[0] Text_Node - no value
[1] Element_Node - value1
[2] Text_Node - no value
[3] Element_Node - value2
[4] Text_Node - no value
[5] Element_Node - value3
[6] Text_Node - no value
The values are then available by using the 'Get Node Text Content VI" function on the correct elements. To open the XML file in the first place I use the Load File Method.
It all seems rather unnecessary.
05-24-2012 10:24 AM
Hi!
The fake text nodes you see are probably due to end of line characters.
Try this:
removing all end of line characters you get only the 3 nodes you are looking for.
Regards,
Marco