You can write xpaths like this
my $firstWeightXpath = qq{ //*:data[ attribute:key="$weightKey" ] [0] };
I use this helper , allows you to use it on dom and nodes, like
$dom->F( '//what:ever', 'what' => 'urn:yeahwhatever', 'that' => 'urn:thatalso', )->[0]->F('//what:else/that:there'); sub XML::LibXML::Node::F { my $self = shift; my $xpath = shift; my %prefix = @_; our $XPATHCONTEXT; $XPATHCONTEXT ||= XML::LibXML::XPathContext->new(); while( my( $p, $u ) = each %prefix ){ $XPATHCONTEXT->registerNs( $p, $u ); } $XPATHCONTEXT->findnodes( $xpath, $self ); }
Example of usage at Re^2: XML namespace question
I also use xpather.pl
In reply to Re: XML::LibXML with namespace with no prefix
by Anonymous Monk
in thread XML::LibXML with namespace with no prefix
by dallen16
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |