If I got it right, / means that the node right to it must be an immediate child of the node left to it, e.g. /ul/li returns li items which are immediate children of a ul item which is the document root. //ul//li returns li items which are descendants of any ul item which is somewhere in the document.
Now: Is /ul/li faster than //ul//li, even if the result set is the same?
Generally speaking, yes, of course!
/ul/livisits at most (number_of_ul * number_of_li nodes), with a maximum depth of 2.//ul//licould potentially visit every node in the document.However, you may be using a document system with some kind of indexing, or you could have a document where the same number of nodes ends up getting visited, or whatever, which could either make
//not as slow or or the same speed as or possibly even faster than/ul/li. I guess you could also potentially have a super-dumb XPath implementation that visits every node anyway.You should profile your specific scenario rather than ask which is faster. “It depends” is the answer.