jjap has asked for the wisdom of the Perl Monks concerning the following question:
I am navigating a nested XML data structure and at some point, I want to retrieve the value of a tag having a specific attribute. I cannot figure out why I am not getting anything from the minimal reproducible below (return 0).
minimal.xmluse strict; use XML::LibXML; my $parser = XML::LibXML->new; my $doc = $parser->parse_file("minimal.xml"); my @vol = $doc->findnodes(q {Volume[@VolumeCategory="L"]}); # also tried various quoting scheme... my $tmp = scalar(@vol); print "Number of entries: $tmp \n"; # 0
Any hints would be greatly appreciated!<root> <ProductKey>99</ProductKey> <Volume VolumeCategory="L" MeasurementCategory="Real">0.063</Volume> <Volume VolumeCategory="cuft" MeasurementCategory="Real">2.2</Volume> </root>
Update: Thanks to both Ikegami and Toolic for great pointers.
Also did some spelling edit.
|
|---|