src/HtmlHelper.php
protected function traverseHeaderTags(\DOMDocument $domDocument, $topLevel, $depth)
    {
        $xpath = new \DOMXPath($domDocument);

        $xpathQuery = sprintf(
            "//*[%s]",
            implode(' or ', array_map(function($v) {
                return sprintf('local-name() = "%s"', $v);
            }, $this->determineHeaderTags($topLevel, $depth)))
        );

        $nodes = [];
        foreach ($xpath->query($xpathQuery) as $node) {
            $nodes[] = $node;
        }

        return new \ArrayIterator($nodes);
    }
protected function traverseHeaderTags(\DOMDocument $domDocument, $topLevel, $depth)
    {
        $xpath = new \DOMXPath($domDocument);

        $xpathQuery = sprintf(
            "//*[%s]",
            implode(' or ', array_map(function($v) {
                return sprintf('local-name() = "%s"', $v);
            }, $this->determineHeaderTags($topLevel, $depth)))
        );

        $nodes = [];
        foreach ($xpath->query($xpathQuery) as $node) {
            $nodes[] = $node;
        }

        return new \ArrayIterator($nodes);
    }
protected function traverseHeaderTags ( \ DOMDocument $ domDocument , $ topLevel , $ depth ) { $ xpath = new \ DOMXPath ( $ domDocument ) ; $ xpathQuery = sprintf ( "//*[%s]" , implode ( ' or ' , array_map ( function ( $ v ) { return sprintf ( 'local-name() = "%s"' , $ v ) ; } , $ this -> determineHeaderTags ( $ topLevel , $ depth ) ) ) ) ; $ nodes = [ ] ; foreach ( $ xpath -> query ( $ xpathQuery ) as $ node ) { $ nodes [ ] = $ node ; } return new \ ArrayIterator ( $ nodes ) ; }
Traverse Header Tags in DOM Document

@param \DOMDocument $domDocument
@param int          $topLevel
@param int          $depth
@return \ArrayIterator|\DomElement[]
Traverse Header Tags in DOM Document