I'm using Perl and XML::LibXML, and the XML I have to deal with looks like this:
<PARAM NAME = "A"><VALUE>1</VALUE>
<PARAM NAME = "B"><VALUE>3</VALUE>
<PARAM NAME = "C"><VALUE>43</VALUE>
<PARAM NAME = "A"><VALUE>6</VALUE>
<PARAM NAME = "B"><VALUE>3</VALUE>
<PARAM NAME = "C"><VALUE>13</VALUE>
.
.
.
The output I need is basically:
A B C
1 3 43
6 3 13
I've put the literal node names into an array like this:
my @attributes = (
'./PARAM[@NAME = "A"]/VALUE',
'./PARAM[@NAME = "B"]/VALUE',
.
.
);
and then have used findnodes() and findvalue() with these xpath literals as the arguments in a foreach loop in a mistaken attempt to get a 'set' of values out, to write to a record. Naturally, findnodes() is wrong because it gets all nodes that meet the criteria in each pass through the loop (as it's supposed to do), and findvalues() is wrong because it in effect does the same thing, just concatenating all the like-named node values.
Since this file is structured the way it is, I see no way to do capture the 'A thru C' nodes/values, write a record, then repeat...at least not without checking every node to see if it's the 'last one' ('C'). Seems I need to process this as a plain old text file, basically.