xml again..
I want to select a sub set of nodes ( for pagination purposes ) from a set.
$nodes = $xml->query(//parent
/child[sex = 'male'
and position() >= 10
and position() < 21]);
If I'm not mistaken that would only select male children who are the 10th to 20th child.
what I need is to select the first 10-20 (or 30-40) males in the set...
sure I'm being a noob and have done this before but its friday...
ta peeps
Find the first element by CSS selector. Find the first element by tag name. Find the first element by partial link text. In order to get the first element of an ID or name of an element, we can use the XPath to display the first value of an element.
The key part of this XPath is *[1] , which will select the node value of the first child of Department .
For the div element with an id attribute of hero //div[@id='hero'] , these XPath expression will select elements as follows: //div[@id='hero']/* will select all of its children elements. //div[@id='hero']/img will select all of its children img elements. //div[@id='hero']//* will select all of its descendent elements.
Have the position condition operate on the result nodeset of your initial condition:
//parent/child[sex='male'][position() >= 10 and position() < 21]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With