Justudo has asked for the wisdom of the Perl Monks concerning the following question:
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]');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XPath search qn
by pizza_milkshake (Monk) on May 05, 2004 at 05:38 UTC | |
by Justudo (Novice) on May 05, 2004 at 08:08 UTC | |
|
Re: XPath search qn
by dakkar (Hermit) on May 05, 2004 at 12:08 UTC | |
by pizza_milkshake (Monk) on May 05, 2004 at 14:16 UTC |