So if I would require all the files with version "v1.3", I would have to extract all "nameprop" nodes as below, and if the string is "Version", i'll get the equivalent string of valueprop and then do a comparison.<file> <name>test.doc</name> <userprop> <nameprop>Effective Date</nameprop> <valueprop>16-Dec-2003</valueprop> </userprop> <userprop> <nameprop>Owner</nameprop> <valueprop>Adrian.Johnston</valueprop> </userprop> <userprop> <nameprop>Version</nameprop> <valueprop>v1.3</valueprop> </userprop> </file> <file> ... </file>
However, if the XML for userprops was stored as attributes as below :my $nodeset = $xpath->find('//file/userprop/nameprop'); ... $valu_node = $xpath->find('../valueprop',$node)->get_node(1);
Then, I could have taken easier XPath search of :<userprop name="Version">v1.3</userprop>
to derive all the version nodes. And then if they are "v1.3", I print out the file name. So qn is, is there any simple way to use XPath if my XML format is using sub-elements for "userprop", as in the first listing above. Thanks.my $nodeset = $xpath->find('//file/userprop/[@name='v1.3]');
In reply to XPath search qn by Justudo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |