为什么我会得到“一个”呢;“没有找到的路径”;XML::XPath中的错误?
我正在尝试运行我创建的Perl文件为什么我会得到“一个”呢;“没有找到的路径”;XML::XPath中的错误?,xml,perl,Xml,Perl,我正在尝试运行我创建的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 match
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";
}
当我运行perlxmlfile.pl
时,我得到了这个错误
"No path to find at /usr/lib/per5/site_perl/5.8.8/XML/XPath.pm line 65"
它期待着
perl xmlfile.pl file.xml /some/xpath
程序需要命令行参数,首先是文件名,然后是XPath表达式。这就是暗示。尝试:
perl xmlfile.pl ex07_xpathdata.xml '//item'