0
這裏是第一個示例中調用documentElemtent
多餘的?XML :: LibXML:doc - root
#!/usr/bin/env perl
use warnings;
use strict;
use XML::LibXML;
my $file = 'xml_file';
my $doc = XML::LibXML->load_xml(location => $file);
my $root = $doc->documentElement();
my $xpc = XML::LibXML::XPathContext->new($root);
# ...
say $_->nodeName for $xpc->findnodes('/');
輸出
#document
$doc = XML::LibXML->load_xml(location => $file);
$xpc = XML::LibXML::XPathContext->new($doc);
# ...
say $_->nodeName for $xpc->findnodes('/');
輸出也
#document
如果有根節點上聲明namepsaces它可能關係。 – ikegami