I am using PHP to read data from an XML file with XPath expressions.

I am new to XPath and wondered if there was a way an XPath expression could be written to only return unique (and ideally sorted) expressions? Is this in fact the goals of XQuery? Does PHP have XQuery support anyone?

For example I have the following line in PHP that pulls out the various function types from an XML file (where <type> is a child node of <function>):

PHP Code:
$func_types $ctx->xpath_eval("//functions/function/type/text()"); 
This returns all function types into the $func_types array, with all the duplicates and in no order.

Ideally I want a unique set of sorted function types returned, not the whole lot.

I am vaguely aware that I could do this in XSL, but that would be overkill here. Of course I could process the XPath result in PHP, but that is not as elegant as it could/should be.