Variables declared with my inside a block { .. } are not accessible outside the block. You probably want something like
pojsub get_xpath_value { my ($xpath) = @_; my @nodes = $root->findnodes($xpath); my ($name,$value); # declare outside block if (defined $nodes[0]) { $value = $nodes[0]->text; # still accessible inside block $name = $nodes[0]->getName; } else { $value = 'not defined'; # or whatever you want $name = 'not defined'; } return ($name,$value); }
In reply to Re^11: Xpath value query
by poj
in thread Xpath value query
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |