To access attribute value use getNamedItem() method :
<?php
$imgNode = $dom->querySelector('figure img');
echo $imgNode->attributes->getNamedItem('src')->value,"\n";
?>
(PHP 8 >= 8.4.0)
Represents the set of attributes on an element.
Зауваження: The DOM extension uses UTF-8 encoding when working with methods or properties. The parser methods auto-detect the encoding or allow the caller to specify an encoding.
To access attribute value use getNamedItem() method :
<?php
$imgNode = $dom->querySelector('figure img');
echo $imgNode->attributes->getNamedItem('src')->value,"\n";
?>