private function importNodes($content, callable $import_function)
    {
        if (\is_array($content)) {
            foreach ($content as $item) {
                $this->importNodes($item, $import_function);
            }
        } else {
            if (\is_string($content) && strpos($content, "\n") !== false) {
                $this->preserve_no_newlines = false;
                if (isset($this->root_instance)) {
                    $this->root_instance->preserve_no_newlines = false;
                }
            }

            if (!($content instanceof self)) {
                $content = new self($content);
            }

            foreach ($this->nodes as $node) {
                foreach ($content->getNodes() as $content_node) {
                    if ($content_node->ownerDocument === $node->ownerDocument) {
                        $imported_node = $content_node->cloneNode(true);
                    } else {
                        $imported_node = $this->document->importNode($content_node, true);
                    }
                    $import_function($node, $imported_node);
                }
            }
        }
    }
private function importNodes($content, callable $import_function)
    {
        if (\is_array($content)) {
            foreach ($content as $item) {
                $this->importNodes($item, $import_function);
            }
        } else {
            if (\is_string($content) && strpos($content, "\n") !== false) {
                $this->preserve_no_newlines = false;
                if (isset($this->root_instance)) {
                    $this->root_instance->preserve_no_newlines = false;
                }
            }

            if (!($content instanceof self)) {
                $content = new self($content);
            }

            foreach ($this->nodes as $node) {
                foreach ($content->getNodes() as $content_node) {
                    if ($content_node->ownerDocument === $node->ownerDocument) {
                        $imported_node = $content_node->cloneNode(true);
                    } else {
                        $imported_node = $this->document->importNode($content_node, true);
                    }
                    $import_function($node, $imported_node);
                }
            }
        }
    }
private function importNodes ( $ content , callable $ import_function ) { if ( \ is_array ( $ content ) ) { foreach ( $ content as $ item ) { $ this -> importNodes ( $ item , $ import_function ) ; } } else { if ( \ is_string ( $ content ) && strpos ( $ content , "\n" ) !== false ) { $ this -> preserve_no_newlines = false ; if ( isset ( $ this -> root_instance ) ) { $ this -> root_instance -> preserve_no_newlines = false ; } } if ( ! ( $ content instanceof self ) ) { $ content = new self ( $ content ) ; } foreach ( $ this -> nodes as $ node ) { foreach ( $ content -> getNodes ( ) as $ content_node ) { if ( $ content_node -> ownerDocument === $ node -> ownerDocument ) { $ imported_node = $ content_node -> cloneNode ( true ) ; } else { $ imported_node = $ this -> document -> importNode ( $ content_node , true ) ; } $ import_function ( $ node , $ imported_node ) ; } } } }
Import nodes and insert or append them via callback function

@param string|self|array $content
@param callable $import_function

@return void
Import nodes and insert or append them via callback function