Re: Last tango in Paris
Brought to you by:
bs_php,
nigelswinson
From: Nigel S. <nig...@us...> - 2002-02-20 23:58:43
|
> If I have a lot of tango nodes with a place attribute, and I want to find the > 5th tango in Paris, according to the Xpath definition, I should be able to do: > > tango[@place="Paris"][5] > > similarly, if I want to find the last tango in Paris, I should be able to do: > > tango[@place="Paris"][last()] > > However, I've tried numerous variations on this in the usecases testbench and > can't get it to work - it either finds nothing or tells me there's an invalid > number of brackets. I can find all the tangos in Paris, and the last tango, > but not the two together. Is this a bug, something not handled (yet?), or is > there some other notation I can use? (ok, I know I can fetch all the tangos > in Paris and then use PHP to get the last in the array.) I wonder if this is related to the fact that //*[last()] returns multiple nodes instead of one? I tried: //employee[(@gender='m') and (position() = last())] against: company-structure.xml at: http://www.carrubbers.org/scripts/php/xpath/testBench/useCases/index.php And it returns: [0] => /company[1]/department[1]/employee[2] [1] => /company[1]/department[2]/employee[2] [2] => /company[1]/department[4]/employee[2] [3] => /company[1]/department[5]/employee[2] Where: //employee[(@gender='m')] Returns: [0] => /company[1]/department[1]/employee[1] [1] => /company[1]/department[1]/employee[2] [2] => /company[1]/department[2]/employee[1] [3] => /company[1]/department[2]/employee[2] [4] => /company[1]/department[3]/employee[1] [5] => /company[1]/department[4]/employee[1] [6] => /company[1]/department[4]/employee[2] [7] => /company[1]/department[5]/employee[1] [8] => /company[1]/department[5]/employee[2] Is that any use?? Nigel =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |