in reply to XML::LibXML question: How to list XInclude files, which are supposed to be included?
use strict; use warnings; use feature qw( say ); use XML::LibXML qw( ); use XML::LibXML::XPathContext qw( ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_file($qfn); my $xpc = XML::LibXML::XPathContext->new($doc); $xpc->registerNs('xi', 'http://www.w3.org/2001/XInclude'); for ($xpc->findnodes('//xi:include/@href')) { say $_->getValue(); }
Also works,
for ($xpc->findnodes('//xi:include')) { say $_->getAttribute('href'); }
Update: Fixed constructor.
|
|---|