Results 1 to 1 of 1
Jul 13, 2004, 08:38 #1
- Join Date
- Nov 2003
- Lake District, UK
- 0 Post(s)
- 0 Thread(s)
Can an XPath expression return unique and sorted values?
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>):
$func_types = $ctx->xpath_eval("//functions/function/type/text()");
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.