#!/usr/bin/env perl use warnings; use strict; our $XML = <<'_END_XML_'; ] >
_END_XML_ use XML::LibXML (); print $XML::LibXML::VERSION, " ", XML::LibXML::LIBXML_DOTTED_VERSION, " ", XML::LibXML::LIBXML_VERSION, " ", XML::LibXML::LIBXML_RUNTIME_VERSION, "\n"; my $dom = XML::LibXML->load_xml(string=>$XML); my $xpc = XML::LibXML::XPathContext->new($dom); $xpc->registerNs(xh => 'http://www.w3.org/1999/xhtml'); for my $div ($xpc->findnodes('//xh:div[@class="data"]')) { print "1:", $div->{id}, "\n" } for my $div ($xpc->findnodes('//xh:div')) { print "2:", $div->{id}, " ", $div->{class}, "\n" } use XML::XSH2 'xsh'; print $XML::XSH2::VERSION, "\n"; xsh(<<'_END_XSH_'); open :s {$::XML} ; register-namespace xh http://www.w3.org/1999/xhtml ; for //xh:div[@class="data"] { echo "a:" @id ; } for //xh:div { echo "b:" @id @class ; } _END_XSH_ __END__ 2.0130 2.9.1 20901 20901 1:One 1:Two 1:Three 2:One data 2:Two data 2:Three data 2.1.26 parsing string done. a: One b: One data b: Two data b: Three data