in reply to Re^2: Finding node with attribute XML::LibXML
in thread Finding node with attribute XML::LibXML
which can be abbreviated to/descendant::Volume[@VolumeCategory="L"]
//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 | |
by ikegami (Patriarch) on Oct 01, 2014 at 16:09 UTC |