Skip to content

[Dom-Crawler] Crawler change node structure #28596

@vistarsvo

Description

@vistarsvo

Symfony DOM-Crawler version(s) affected: 4.1

Description
Hi. I have interesting bug, when Crawler change node structure. I can't parse html value.

Original content is:
<h1><p class="wide_title" id="pPageHeader">Szukanie zaawansowane</p></h1>

After echo (new Crawler($this->content))->html() :

 <h1></h1>
<p class="wide_title" id="pPageHeader">Szukanie zaawansowane</p>

So, output is empty :( :

$crawler = new Crawler($content);
foreach($crawler->filter('h1') as $h1DomElement) {
   echo $h1DomElement->nodeValue . PHP_EOL;
}

OS: Ubuntu 18.04
PHP ver: PHP 7.1.20-1+ubuntu18.04.1+deb.sury.org+1

Also has same problem on another envirounment:
OS: CentOS
PHP 7.1.20 (cli) (built: Jul 19 2018 10:10:15) ( NTS )

Html page

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl-PL" >
<head>
	<link rel="dns-prefetch" href="https://github.com//www.google.com" />
</head>
<body>
	<noscript>
        <link rel="stylesheet" type="text/css" href="https://github.com/css/layout/noscript.css">
        <div class="noscript-error">
	        Some text
        </div>
	</noscript>

    <div class="serp">
        <div class="serp_cont">
            <div class="search_form_pnl new-sf_pnl">
                <div class="stopper"></div>
                    <div class="right-items_wr">
                        <div class="user_wrapper">
                            ...
                        </div>
                    </div>
            </div>
            <div>
                <h1><p class="wide_title" id="pPageHeader">Szukanie zaawansowane</p></h1>
            </div>
            <div class="subs_edit wide_panel">
                <form action="/Help/WideSearch" method="post">   
                </form>        
            </div>
        </div>
    </div>

</body>
</html>

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions