Pressbooks\Modules\Import\Ooxml\Docx::findTheNode PHP Метод

findTheNode() защищенный Метод

Recursive iterator to locate and return a specific node, targeting child nodes
protected findTheNode ( DOMNode $node, string $chapter_name ) : DOMNode
$node DOMNode
$chapter_name string
Результат DOMNode
    protected function findTheNode(\DOMNode $node, $chapter_name)
    {
        if (XML_ELEMENT_NODE !== $node->nodeType) {
            return '';
        }
        $currentTag = $node->tagName;
        $currentValue = trim($node->nodeValue);
        if ($chapter_name == $currentValue && $this->tag == $currentTag) {
            return $node;
        }
        // test
        if ($node->hasChildNodes()) {
            $nodeList = $node->childNodes;
            for ($i = 0; $i < $nodeList->length; $i++) {
                if ($nodeList->item($i)->nodeType !== XML_ELEMENT_NODE) {
                    continue;
                }
                if ($chapter_name != $nodeList->item($i)->nodeValue && $this->tag != $nodeList->item($i)->tagName) {
                    // recursive
                    return $this->findTheNode($nodeList->item($i), $chapter_name);
                }
            }
        }
        return '';
    }