On May 2, 2004, at 6:58 PM, Ingo Weiss wrote:
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];
and others, but nothing worked so far. Any suggestion anybody?
The findnodes() method returns an XML::LibXML::NodeList object in scalar context. The XML::LibXML::NodeList class includes a shift() method that works like Perl's built-in function. So you might try this:
$myNode = $xmlDox->findnodes("XPathExpression")->shift();sherm--
