Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 78a49a9

Browse filesBrowse files
javiereguiluzxabbuh
authored andcommitted
Explained the DomCrawler charset guessing mechanism
1 parent 4f94c5e commit 78a49a9
Copy full SHA for 78a49a9

File tree

Expand file treeCollapse file tree

1 file changed

+16
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-7
lines changed

‎components/dom_crawler.rst

Copy file name to clipboardExpand all lines: components/dom_crawler.rst
+16-7Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,19 @@ The crawler supports multiple ways of adding the content::
237237

238238
.. note::
239239

240-
When dealing with character sets other than ISO-8859-1, always add HTML
241-
content using the :method:`Symfony\\Component\\DomCrawler\\Crawler::addHtmlContent`
242-
method where you can specify the second parameter to be your target character
243-
set.
240+
The :method:`Symfony\\Component\\DomCrawler\\Crawler::addHtmlContent` and
241+
:method:`Symfony\\Component\\DomCrawler\\Crawler::addXmlContent` methods
242+
default to UTF-8 encoding but you can change this behavior with their second
243+
optional argument.
244+
245+
The :method:`Symfony\\Component\\DomCrawler\\Crawler::addContent` method
246+
guesses the best charset according to the given contents and defaults to
247+
``ISO-8859-1`` in case no charset can be guessed.
248+
249+
.. versionadded:: 3.4
250+
The charset guessing mechanism of the ``addContent()`` method was
251+
introduced in Symfony 3.4. In previous Symfony versions, ``ISO-8859-1``
252+
charset was always used.
244253

245254
As the Crawler's implementation is based on the DOM extension, it is also able
246255
to interact with native :phpclass:`DOMDocument`, :phpclass:`DOMNodeList`
@@ -397,13 +406,13 @@ a :class:`Symfony\\Component\\DomCrawler\\Form` object that represents the
397406
form that the button lives in::
398407

399408
// button example: <button id="my-super-button" type="submit">My super button</button>
400-
409+
401410
// you can get button by its label
402411
$form = $crawler->selectButton('My super button')->form();
403-
412+
404413
// or by button id (#my-super-button) if the button doesn't have a label
405414
$form = $crawler->selectButton('my-super-button')->form();
406-
415+
407416
// or you can filter the whole form, for example a form has a class attribute: <form class="form-vertical" method="POST">
408417
$crawler->filter('.form-vertical')->form();
409418

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.