Use the optional argument to
DOMDocument::saveHTML: this says "output this element only".
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: