0

I can get all image elements in the DOM like this:

$element->getElementsByTagName('img')

How can I get all image and iframe elements in the DOM in one request? Something like:

$element->getElementsByTagName('img, iframe')
2
  • This might help! stackoverflow.com/questions/7906581/… Commented Jan 23, 2018 at 6:08
  • 1
    @algoriyhtsmts Thanks for the help. That's what I was looking for. Commented Jan 23, 2018 at 17:18

1 Answer 1

1

Using getElementsByTagName you cannot get multiple elements by tag name. You can get one tag at a time only. To achieve this, there are two ways

Calling Tag for two times

$element->getElementsByTagName('img')
$element->getElementsByTagName('iframe')

OR

Using JavaScript

document.querySelectorAll('img,ifame')

PS: I would not recommend using PHP for DOM parsing because that will impact page performance.

Hope this helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.