Ii have the follow structure:
<div class="xGh" style="background-image: url('name_file.jpg');"></div>
I need that output:
name_file.jpg
I try use that answer, but dont work fo me :
$img = $xpath->query(substring-before(substring-after(//div[@class='xGh']/@style, "background-image: url('"), "')"));
echo $img->item($i)->nodeValue."<br/>";
Look the error:
Test Ideone with error
I have some error in that sintaxe i cant see how is correct...
sry my english
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