public function expand(DOMNode $basenode = null)
    {
        if (null === $basenode) {
            $basenode = new DomDocument();
        }

        if ($basenode instanceof DOMDocument) {
            $doc = $basenode;
        } else {
            $doc = $basenode->ownerDocument;
        }

        if (false === $node = $this->reader->expand($basenode)) {
            throw new BadMethodCallException('Unable to expand node.');
        }

        if ($node->ownerDocument !== $doc) {
            $node = $doc->importNode($node, true);
        }

        return $node;
    }
public function expand(DOMNode $basenode = null)
    {
        if (null === $basenode) {
            $basenode = new DomDocument();
        }

        if ($basenode instanceof DOMDocument) {
            $doc = $basenode;
        } else {
            $doc = $basenode->ownerDocument;
        }

        if (false === $node = $this->reader->expand($basenode)) {
            throw new BadMethodCallException('Unable to expand node.');
        }

        if ($node->ownerDocument !== $doc) {
            $node = $doc->importNode($node, true);
        }

        return $node;
    }
public function expand ( DOMNode $ basenode = null ) { if ( null === $ basenode ) { $ basenode = new DomDocument ( ) ; } if ( $ basenode instanceof DOMDocument ) { $ doc = $ basenode ; } else { $ doc = $ basenode -> ownerDocument ; } if ( false === $ node = $ this -> reader -> expand ( $ basenode ) ) { throw new BadMethodCallException ( 'Unable to expand node.' ) ; } if ( $ node -> ownerDocument !== $ doc ) { $ node = $ doc -> importNode ( $ node , true ) ; } return $ node ; }
XMLReader expand node and import it into a DOMNode with a DOMDocument

This is for example useful for DOMDocument::saveXML() @see readOuterXml
or getting a SimpleXMLElement out of it @see getSimpleXMLElement

@throws BadMethodCallException
@param DOMNode $basenode
@return DOMNode
XMLReader expand node and import it into a DOMNode with a DOMDocument