From 569b8a9720aa7aed353ce97ad5f0f35595a5eeba Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 3 Oct 2017 17:40:56 +0200 Subject: [PATCH 1/2] Explained the DomCrawler charset guessing mechanism --- components/dom_crawler.rst | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 616d0ada91f..69ffcaf286b 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -237,10 +237,19 @@ The crawler supports multiple ways of adding the content:: .. note:: - When dealing with character sets other than ISO-8859-1, always add HTML - content using the :method:`Symfony\\Component\\DomCrawler\\Crawler::addHtmlContent` - method where you can specify the second parameter to be your target character - set. + The :method:`Symfony\\Component\\DomCrawler\\Crawler::addHtmlContent` and + :method:`Symfony\\Component\\DomCrawler\\Crawler::addXmlContent` methods + default to UTF-8 encoding but you can change this behavior with their second + optional argument. + + The :method:`Symfony\\Component\\DomCrawler\\Crawler::addContent` method + detects the best charset according to the given contents and defaults to + ``ISO-8859-1`` in case no charset can be guessed. + + .. versionadded:: 3.4 + The charst guessing mechanism of the ``addContent()`` method was added + in Symfony 3.4. In previous Symfony versions, ``ISO-8859-1`` charset was + always used. As the Crawler's implementation is based on the DOM extension, it is also able to interact with native :phpclass:`DOMDocument`, :phpclass:`DOMNodeList` @@ -397,13 +406,13 @@ a :class:`Symfony\\Component\\DomCrawler\\Form` object that represents the form that the button lives in:: // button example: - + // you can get button by its label $form = $crawler->selectButton('My super button')->form(); - + // or by button id (#my-super-button) if the button doesn't have a label $form = $crawler->selectButton('my-super-button')->form(); - + // or you can filter the whole form, for example a form has a class attribute:
$crawler->filter('.form-vertical')->form(); From 12cdccad08a5f3fc397851e1a4c3c2b9f6639d89 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 6 Oct 2017 17:53:51 +0200 Subject: [PATCH 2/2] Minor reword --- components/dom_crawler.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 69ffcaf286b..9be4071c1b4 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -243,13 +243,13 @@ The crawler supports multiple ways of adding the content:: optional argument. The :method:`Symfony\\Component\\DomCrawler\\Crawler::addContent` method - detects the best charset according to the given contents and defaults to + guesses the best charset according to the given contents and defaults to ``ISO-8859-1`` in case no charset can be guessed. .. versionadded:: 3.4 - The charst guessing mechanism of the ``addContent()`` method was added - in Symfony 3.4. In previous Symfony versions, ``ISO-8859-1`` charset was - always used. + The charset guessing mechanism of the ``addContent()`` method was + introduced in Symfony 3.4. In previous Symfony versions, ``ISO-8859-1`` + charset was always used. As the Crawler's implementation is based on the DOM extension, it is also able to interact with native :phpclass:`DOMDocument`, :phpclass:`DOMNodeList`