Symfony CSS selector

Code
<?php

use Symfony\Component\CssSelector\CssSelectorConverter;

$xpathStr = (new CssSelectorConverter())->toXpath('h1:first-child');

$file __DIR__ '/templates/site.html';

// ###### using PHP DOM ######

$dom = new DOMDocument();
$dom->loadHTMLFile($file);

$xpath = new DOMXPath($dom);
$domElement $xpath->evaluate($xpathStr)->item(0);

echo 
$domElement->nodeValue PHP_EOL;
Result
PHPSnippets
Used Versions
PHP 8.2, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8