@@ -285,12 +285,15 @@ and :phpclass:`DOMNode` objects:
285285Expression Evaluation
286286~~~~~~~~~~~~~~~~~~~~~
287287
288- The ``evaluate() `` method evaluates the given XPath expression.
289- The return value depends on if the expression operates on simple values
290- (like HTML attributes), or a subset of the current document.
291- If the expression evaluates to a scalar value, an array of results will be
292- returned. If the expression evaluates to a DOM document, a new ``Crawler ``
293- instance will be returned.
288+ .. versionadded ::
289+ The :method: `Symfony\\ Component\\ DomCrawler\\ Crawler::evaluate ` method was
290+ introduced in Symfony 3.2.
291+
292+ The ``evaluate() `` method evaluates the given XPath expression. The return
293+ value depends on the XPath expression. If the expression evaluates to a scalar
294+ value (e.g. HTML attributes), an array of results will be returned. If the
295+ expression evaluates to a DOM document, a new ``Crawler `` instance will be
296+ returned.
294297
295298This behavior is best illustrated with examples::
296299
@@ -308,31 +311,35 @@ This behavior is best illustrated with examples::
308311 $crawler->addHtmlContent($html);
309312
310313 $crawler->filterXPath('//span[contains(@id, "article-")]')->evaluate('substring-after(@id, "-")');
311- // array:3 [
312- // 0 => "100"
313- // 1 => "101"
314- // 2 => "102"
315- // ]
314+ /* array:3 [
315+ 0 => "100"
316+ 1 => "101"
317+ 2 => "102"
318+ ]
319+ */
316320
317321 $crawler->evaluate('substring-after(//span[contains(@id, "article-")]/@id, "-")');
318- // array:1 [
319- // 0 => "100"
320- // ]
322+ /* array:1 [
323+ 0 => "100"
324+ ]
325+ */
321326
322327 $crawler->filterXPath('//span[@class="article"]')->evaluate('count(@id)');
323- // array:3 [
324- // 0 => 1.0
325- // 1 => 1.0
326- // 2 => 1.0
327- // ]
328+ /* array:3 [
329+ 0 => 1.0
330+ 1 => 1.0
331+ 2 => 1.0
332+ ]
333+ */
328334
329335 $crawler->evaluate('count(//span[@class="article"])');
330- // array:1 [
331- // 0 => 3.0
332- // ]
336+ /* array:1 [
337+ 0 => 3.0
338+ ]
339+ */
333340
334341 $crawler->evaluate('//span[1]');
335- // Symfony\Component\DomCrawler\Crawler { }
342+ // A Symfony\Component\DomCrawler\Crawler instance
336343
337344Links
338345~~~~~
0 commit comments