3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div class="d-xl-none"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-top-menu"> <i class="icon-grid3"></i> </button> </div> <div class='class_1'> <span>test</span> </div> HTML; $xml = simplexml_load_string("<root>{$html}</root>"); echo $xml->xpath('//div[@class="d-xl-none"]/*')[0]->asXML(); echo PHP_EOL, '===========================', PHP_EOL; echo $xml->xpath('//div[@class="class_1"]/*')[0]->asXML();
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-top-menu"> <i class="icon-grid3"/> </button> =========================== <span>test</span>

preferences:
165.22 ms | 403 KiB | 178 Q