in reply to Re^10: Xpath value query
in thread Xpath value query

Variables declared with my inside a block { .. } are not accessible outside the block. You probably want something like

sub 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); }
poj