0

我正在尝试运行我创建的 Perl 文件。

use XML::XPath;
use XML::XPath::XMLParser;

# create an object to parse the file and field XPath queries
my $xpath = XML::XPath->new( filename => shift @ARGV );

# apply the path from the command line and get back a list matches
my $nodeset = $xpath->find( shift @ARGV );

# print each node in the list
foreach my $node ( $nodeset->get_nodelist ) {
  print XML::XPath::XMLParser::as_string( $node ) . "\n";
}

当我运行时perl xmlfile.pl出现此错误

"No path to find at /usr/lib/per5/site_perl/5.8.8/XML/XPath.pm line 65"
4

2 回答 2

0

它在期待

perl xmlfile.pl file.xml /some/xpath
于 2012-06-25T17:18:09.537 回答
0

该程序需要命令行参数,首先是文件名,然后是 XPath 表达式。@ARGV是提示。尝试:

perl xmlfile.pl ex07_xpathdata.xml '//item'
于 2012-06-25T17:18:29.287 回答