I have a following HTML code:
<div class="article__img has-caption" style="background-image: url('img/main/article-plug.png')" >
I'm trying to extract an image URL and replace it with another (for example img/main/article-plug.webp) but I'm stuck with XPath queries and don't know what to do.
Thanks for help in advance!
That's my last code (but it doesn't return anything yet):
$domDocument = new DOMDocument();
$domDocument->loadHTML($article["DESCRIPTION"]);
$domXPath = new DOMXPath($domDocument);
$img = $domXPath->query('substring-before(substring-after(//div[@class=\'article__img has-caption\']/@style, "background-image: url(\'"), "\')")');