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.
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
Post a Comment