Description
The following code:
<?php
$html = <<<HTML
<b>
<c>
Hello
</c>
<d />
<e />
</b>
HTML;
$dom = HTMLDocument::createFromString($html);
$b = $dom->getElementsByTagName('b')[0];
$childrenOfB = $b->childNodes;
var_dump($childrenOfB[1]->tagName); // C
var_dump($childrenOfB[3]->tagName); // D
var_dump($childrenOfB[5]->tagName); // null, this should be E
var_dump($childrenOfB[3]->childNodes[1]->tagName); // E is somehow a child of D
Resulted in this output: E is a child of D, while it should be a sibling of D and a child of B
Changing the input to the following, does generate the correct result:
$html = <<<HTML
<b>
<c>
Hello
</c>
<d></d>
<e></e>
</b>
HTML;
PHP Version
PHP 8.4.1
Operating System
Mac 15.0.1