src/XmlUtil.php
public static function addNodeFromFile(\DOMNode $rootNode, $filename, $nodetoadd)
    {
        if ($rootNode === null) {
            return;
        }
        if (!file_exists($filename)) {
            return;
        }

        $source = XmlUtil::createXmlDocumentFromFile($filename);

        $nodes = $source->getElementsByTagName($nodetoadd)->item(0)->childNodes;

        foreach ($nodes as $node) {
            $newNode = $rootNode->ownerDocument->importNode($node, true);
            $rootNode->appendChild($newNode);
        }
    }
public static function addNodeFromFile(\DOMNode $rootNode, $filename, $nodetoadd)
    {
        if ($rootNode === null) {
            return;
        }
        if (!file_exists($filename)) {
            return;
        }

        $source = XmlUtil::createXmlDocumentFromFile($filename);

        $nodes = $source->getElementsByTagName($nodetoadd)->item(0)->childNodes;

        foreach ($nodes as $node) {
            $newNode = $rootNode->ownerDocument->importNode($node, true);
            $rootNode->appendChild($newNode);
        }
    }
public static function addNodeFromFile ( \ DOMNode $ rootNode , $ filename , $ nodetoadd ) { if ( $ rootNode === null ) { return ; } if ( ! file_exists ( $ filename ) ) { return ; } $ source = XmlUtil :: createXmlDocumentFromFile ( $ filename ) ; $ nodes = $ source -> getElementsByTagName ( $ nodetoadd ) -> item ( 0 ) -> childNodes ; foreach ( $ nodes as $ node ) { $ newNode = $ rootNode -> ownerDocument -> importNode ( $ node , true ) ; $ rootNode -> appendChild ( $ newNode ) ; } }
Add node to specific XmlNode from file existing on disk

@param \DOMNode $rootNode XmlNode receives node
@param string $filename File to import node
@param string $nodetoadd Node to be added
@throws \ByJG\Util\Exception\XmlUtilException
Add node to specific XmlNode from file existing on disk