http://www.perlmonks.org?node_id=938668


in reply to XML::LibXML count nodes

Try this:

print scalar(@{$doc->findnodes('//category')});

I've done it by assigning the nodes to an array and then just printing the number of elements in the array.