I am having following XML which I required to process
<table><col1>check1</col1><col2>check2</col2><col3>check3</col3><content><data>gt1</data><data>check_gt1</data></content><content><data>gt2</data><data>check_gt2</data></content></table>
I wrote the following code to process this XML
my $parser = XML::LibXML->new();my $respDom = $parser->parse_string($xmldata);my @rowNodes = $respDom->getDocumentElement->findnodes("//content");if(scalar @rowNodes > 0) { print "\nRow nodes size is ".scalar @rowNodes."\n"; foreach my $rowNode (@rowNodes) { my $colNode = $rowNode->findnodes("//data")->[0]; my $num = $colNode->textContent; print "\nNUM is ".$colNode; }}
My result showing the size of node "content" is 2. But it returns "gt1" two times inside the loop, It is not returning "gt2" in the second iteration.
Is there anything I need to change on this ?