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"
In reply to Re: XPath search qn
by pizza_milkshake
in thread XPath search qn
by Justudo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |