Using DOMDocument, is it possible to get all elements that exists within a certain DOM? Using DOMDocument, is it possible to get all elements that exists within a certain DOM? php php

Using DOMDocument, is it possible to get all elements that exists within a certain DOM?


You can pass an asterisk * with getElementsByTagName() which returns all elements:

foreach($dom->getElementsByTagName('*') as $element ){}

From the Manual:

name
The local name (without namespace) of the tag to match on. The special value * matches all tags.