Xpath predicate help again!

Hai folks,

I want to get the secondary people’s first names under listing1.
so the result would be Dorothy and Desmond.

I just the below xpath predicate. but not working it seems.

Note: i cant use [last()-1] here. coz there lot of listing like this. i just posted two listing only.

$result = $xml->xpath('//wp:listing[1]/wp:people/wp:person[wp:rank="secondary"]');

:rolleyes:


<wp:listings>
-<wp:listing>
--<wp:people>

---<wp:person wp:rank="primary">
-----<wp:firstname>Harry</wp:firstname>
---</wp:person>

---<wp:person wp:rank="secondary">
----<wp:firstname>Dorothy</wp:firstname>
---</wp:person>

---<wp:person wp:rank="secondary">
----<wp:firstname>Desmond</wp:firstname>
---</wp:person>

--</wp:people>
-</wp:listing>

-<wp:listing>
--<wp:people>

---<wp:person wp:rank="primary">
-----<wp:firstname>John</wp:firstname>
---</wp:person>

---<wp:person wp:rank="secondary">
----<wp:firstname>jancy</wp:firstname>
---</wp:person>

---<wp:person wp:rank="secondary">
----<wp:firstname>jenny</wp:firstname>
---</wp:person>

--</wp:people>
-</wp:listing>
<wp:listings>

Thanks folks,
problem has been solved.
i should have called the predict another step further.

$result = $xml->xpath('//wp:listing[1]/wp:people/wp:person[@wp:rank="secondary"]/[B]wp:firstname[/B]');