From a2c8fa0d39ff27b33d9b95952971807c66e6b2dd Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 6 Mar 2023 13:49:15 +0100 Subject: [PATCH] [DomCrawler] Give choice of used parser --- components/dom_crawler.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 9bdeed9c8ae..b7f68f1a89f 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -651,8 +651,28 @@ another given base URI:: UriResolver::resolve('?a=b', 'http://localhost/bar#foo'); // http://localhost/bar?a=b UriResolver::resolve('../../', 'http://localhost/'); // http://localhost/ +Using a HTML5 Parser +~~~~~~~~~~~~~~~~~~~~ + +You can specify to the :class:`Symfony\\Component\\DomCrawler\\Crawler` to use +an HTML5 parser when instantiating it by setting the ``useHtml5Parser`` constructor +argument to ``true``:: + + use Symfony\Component\DomCrawler\Crawler; + + $crawler = new Crawler(null, $uri, useHtml5Parser: true); + +By doing do, the crawler will use the parser from the `masterminds/html5`_ library internally to parse +documents. + +.. versionadded:: 6.3 + + The ``useHtml5Parser`` argument was introduced in Symfony 6.3. + Learn more ---------- * :doc:`/testing` * :doc:`/components/css_selector` + +.. _`masterminds/html5`: https://packagist.org/packages/masterminds/html5 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