php - DOMXPath to find specific image tag -


my question direct. here html dom,

<html>    ...   <div class="a b">     <div class="c">        <img src="..." >     </div>   <div>   ...   <div class="a">   </div> ... </html> 

now want image's src in div[class="a b"]-><div class="c">-><img> using domxpath in php code.

the main puzzle not know how write it's path correctly.


update

i have tried how data html using regex, doesn't work still.

the actual html structure : enter image description here

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 $vip)    {       var_dump($vip);    } 

and output :

object(domnodelist)#2 (1) { ["length"]=> int(0) }


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -