Trying to decide which is more appropriate for my use case...
After comparing the documentation for these methods, my vague understanding is
Still not much the wiser! Could anyone explain (in as close as possible to layman's terms) when you would use one or the other - e.g. will the multiple/single results mentioned above always be the case?
DOMXPath::query() supports only expressions that return a node list. DOMXPath::evaluate() supports all valid expressions. The official method is named evaluate(), too: http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathEvaluator
p elements inside a
href attributes in
a elements the current document:
You can use the
string() function to cast the first element of a node list to a string. This will not work with DOMXpath::query().
Select the title text of a document:
There are other function and operators that will change the result type of an expression. But it is always unambiguous. You will always know what type the result is.