Hi All,

I am using XML::LibXML's findnodes method to find XML nodes. Most
of the time I am looking for a single node, but I still need to
write:


@allnodes = $xmlDox->findnodes("XPathExpression");
$myNode = $allNodes[0];

While this works perfectly fine, I find it counterintuitive when
revisiting the code later and I was looking for a more elegant
way without using a temporary variable @allNodes that I shouldn't
really need (looking for a single node). I tried constructs like:


$myNode = shift $xmlDox->findnodes("XPathExpression");

$myNode = ($xmlDox->findnodes("XPathExpression"))[0];


and others, but nothing worked so far.
Any suggestion anybody?

Thanks!
Ingo

Reply via email to