in reply to Re^2: Finding node with attribute XML::LibXML
in thread Finding node with attribute XML::LibXML

If you want to search the whole document, you can use
/descendant::Volume[@VolumeCategory="L"]
which can be abbreviated to
//Volume[@VolumeCategory="L"]

Should I understand that that methods does not support attribute?

If you're asking if getElementsByTagName can filter the returned nodes to retain only those with a specific attribute value, then the answer is no. The only argument it takes is a tag name. You could do

my @matching = grep { my $vc = $_->getAttribute('VolumeCategory'); defined($vc) && $vc eq "L" } $doc->getElementsByTagName('Volume');

but aforementioned

my @matching = $doc->findnodes('//Volume[@VolumeCategory="L"]');

is much simpler.

Replies are listed 'Best First'.
Re^4: Finding node with attribute XML::LibXML
by Jim (Curate) on Oct 01, 2014 at 00:57 UTC

    I think you meant to type…

    /descendant::Volume[@VolumeCategory="L"]

    With just one colon, you get…

    XPath error : Undefined namespace prefix
      Thanks, fixed