in reply to XPath search qn
update: updated the path to suck less. i learned a decent amount about xpath by doing this! :)
#!perl -l use strict; use warnings; use XML::XPath; my $xp = XML::XPath->new("xml" => do { undef $/; <DATA> }); my $path = q{//userprop[nameprop='Version' and valueprop='v1.3']/ances +tor::file}; my $nodes = $xp->find($path); for my $node ($nodes->get_nodelist) { print XML::XPath::XMLParser::as_string($node); } __DATA__ <files> <file> <name>test.doc</name> <userprop> <valueprop>v1.3</valueprop> <nameprop>Version</nameprop> </userprop> </file> <file> <name>test.doc</name> <userprop> <nameprop>Version</nameprop> <valueprop>v1.4</valueprop> </userprop> </file> </files>
perl -e"\$_=qq/nwdd\x7F^n\x7Flm{{llql0}qs\x14/;s/./chr(ord$&^30)/ge;print"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: XPath search qn
by Justudo (Novice) on May 05, 2004 at 08:08 UTC |