My question is very direct. Here is my html
dom,
<html>
...
<div class="A B">
<div class="C">
<img src="..." >
</div>
<div>
...
<div class="A">
</div>
...
</html>
Now I want to get the image's src in div[class="A B"]-><div class="C">-><img>
using DOMXPath
in php
code.
The main puzzle is that I do not know how to write it's path correctly.
Update
I have tried How to get data from HTML using regex, but it doesn't work still.
The actual html structure is :
My php
code:
$doc = new DOMDocument();
$doc->loadHTML($html);
$title = $doc->getElementsByTagName('title')->item(0)->nodeValue;
$XPath = new DOMXPath($doc);
$vipImg = $XPath->query('//div[@class="show-midpic active-pannel"]/a/div[@class="zoomPad"]/img');
var_dump($vipImg);
foreach($vipImg as $vip)
{
var_dump($vip);
}
And the output is :
object(DOMNodeList)#2 (1) { ["length"]=> int(0) }