Get DOM elements by tag name with DOMDocument::loadHTML and getElementsByTagName

后端 未结 2 1344
-上瘾入骨i
-上瘾入骨i 2021-02-07 15:01

Sorry if this is reposted, but I can\'t wrap my mind around it and I\'ve tried all the available documentation and examples I could find.

I am trying to get the first

2条回答
  •  感情败类
    2021-02-07 15:50

    Use this:

    $img = $dom->getElementsByTagName('img')->item(0);
    echo $img->attributes->getNamedItem("src")->value;
    

提交回复
热议问题