thechane has asked for the wisdom of the Perl Monks concerning the following question:

Hello all,

I have been using the exists method in XML::LibXML 1.70 :

if ($tmpnode->exists('Name/OtherName') == 1) { bhah bhah } else { blah blah }

... unfortunately where I am ultimately going to run the script only as XML::LibXML 1.63 with perl 5.8.0 installed and I am unable to have it upgraded. From here it looks like the exists method came about in 1.69 - does anyone know of an easy alternative?

thanks in advance

Replies are listed 'Best First'.
Re: XML::LibXML exists method
by ikegami (Patriarch) on May 05, 2011 at 06:37 UTC

    Maybe

    if ($tmpnode->findnodes('Name/OtherName'))
    or
    if ($tmpnode->findnodes('Name/OtherName')->size > 0)
      exists is pure-perl method implemented using findnodes, just copy paste it into program
Re: XML::LibXML exists method
by Anonymous Monk on May 04, 2011 at 23:53 UTC
    and I am unable to have it upgraded.

    No reason to tie your hands behind your back, take a look at Yes, even you can use CPAN

    does anyone know of an easy alternative?

    copy/paste