Skip to content

Commit cd40f79

Browse files
committed
minor #18009 [DomCrawler] Give choice of used parser (alexandre-daubois)
This PR was merged into the 6.3 branch. Discussion ---------- [DomCrawler] Give choice of used parser Fixes #18007 Commits ------- a2c8fa0 [DomCrawler] Give choice of used parser
2 parents 714e9c9 + a2c8fa0 commit cd40f79

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

components/dom_crawler.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,28 @@ another given base URI::
651651
UriResolver::resolve('?a=b', 'http://localhost/bar#foo'); // http://localhost/bar?a=b
652652
UriResolver::resolve('../../', 'http://localhost/'); // http://localhost/
653653

654+
Using a HTML5 Parser
655+
~~~~~~~~~~~~~~~~~~~~
656+
657+
You can specify to the :class:`Symfony\\Component\\DomCrawler\\Crawler` to use
658+
an HTML5 parser when instantiating it by setting the ``useHtml5Parser`` constructor
659+
argument to ``true``::
660+
661+
use Symfony\Component\DomCrawler\Crawler;
662+
663+
$crawler = new Crawler(null, $uri, useHtml5Parser: true);
664+
665+
By doing do, the crawler will use the parser from the `masterminds/html5`_ library internally to parse
666+
documents.
667+
668+
.. versionadded:: 6.3
669+
670+
The ``useHtml5Parser`` argument was introduced in Symfony 6.3.
671+
654672
Learn more
655673
----------
656674

657675
* :doc:`/testing`
658676
* :doc:`/components/css_selector`
677+
678+
.. _`masterminds/html5`: https://packagist.org/packages/masterminds/html5

0 commit comments

Comments
 (0)
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