I'm trying to get an element by an specific attribute ("data-image-id"
).
I got this:
$dom = new DOMDocument;
@$dom->loadHTML($html);
$xpath = new DOMXpath($dom);
$links = $xpath->query('//div[@data-image-id]/@data-image-id');
die(var_dump($links));
but I got the following:
object(DOMNodeList)#3 (1) { ["length"]=> int(0) }
I just want to get all elements with the attribute "image-data-id"
.
What am I doing wrong?