Use the optional argument to DOMDocument::saveHTML
: this says "output this element only".
return $node->ownerDocument->saveHTML($node);
Note that the argument is only available from PHP 5.3.6. Before that, you need to use DOMDocument::saveXML
instead. The results may be slightly different. Also, if you already have a reference to the document, you can just do this:
$doc->saveHTML($node);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…