Ii have the follow structure:
I need that output:
1) You lost quotes wrapping xpath - it's string.
2) with dom xpath, query returns set of nodes while to receive string result it's better to use evaluate
$img = $xpath->evaluate('substring-before(substring-after(//div[@class=\'xGh\']/@style, "background-image: url(\'"), "\')")');
echo $img; // it contains name_file.jpg
demo