From 851956dd32e226a9d43dbcb40b5662a73145e07c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 18 Jan 2019 11:09:09 +0100 Subject: [PATCH] Documented the default values of text() and html() --- components/dom_crawler.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index e23261c996a..46e75662eda 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -201,8 +201,16 @@ Access the node name (HTML tag name) of the first node of the current selection Access the value of the first node of the current selection:: + // if the node does not exist, calling to text() will result in an exception $message = $crawler->filterXPath('//body/p')->text(); + // avoid the exception passing an argument that text() returns when node does not exist + $message = $crawler->filterXPath('//body/p')->text('Default text content'); + +.. versionadded:: 4.3 + + The default argument of ``text()`` was introduced in Symfony 4.3. + Access the attribute value of the first node of the current selection:: $class = $crawler->filterXPath('//body/p')->attr('class'); @@ -298,8 +306,16 @@ and :phpclass:`DOMNode` objects:: Or you can get the HTML of the first node using :method:`Symfony\\Component\\DomCrawler\\Crawler::html`:: + // if the node does not exist, calling to html() will result in an exception $html = $crawler->html(); + // avoid the exception passing an argument that html() returns when node does not exist + $html = $crawler->html('Default HTML content'); + + .. versionadded:: 4.3 + + The default argument of ``html()`` was introduced in Symfony 4.3. + Expression Evaluation ~~~~~~~~~~~~~~~~~~~~~ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy