mojo-jojo has asked for the wisdom of the Perl Monks concerning the following question:
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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: xpath query
by Anonymous Monk on Dec 27, 2011 at 11:02 UTC | |
by ikegami (Patriarch) on Dec 27, 2011 at 11:13 UTC | |
by mojo-jojo (Novice) on Dec 28, 2011 at 06:03 UTC | |
by mojo-jojo (Novice) on Dec 28, 2011 at 10:27 UTC | |
|
Re: xpath query
by choroba (Cardinal) on Dec 28, 2011 at 14:28 UTC |