I am trying to find tags in an xml file which do not have a particular child. I am using the following code but it gives me an error Use of uninitialized value $local in substitution (s///) at /usr/local/lib/perl5/site_perl/5.10.0/XML/XPath/Node/Element.pm line 138.
A snippet of xml file is given belowmy $xp = XML::XPath->new( filename => $_[0] ); my $nodeset = $xp->find('//descendant-or-self::node()[local-name(. +) = dependency and not(child::version)] '); # find all authors foreach my $node ( $nodeset->get_nodelist ) { print XML::XPath::XMLParser::as_string($node)."\n\n"; }
<project> <dependency> <!-- find all such dependency tags --> <groupId>com.solarmetric</groupId> <artifactId>kodo-jdo-runtime</artifactId> </dependency> <dependency> <groupId>javax.jdo</groupId> <artifactId>jdo</artifactId> <version>1.0.2</version> </dependency> </project>
In reply to xpath query by mojo-jojo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |