converting xml DOMDocument to string
DOMDocument
has a method SaveHTML()
, it's designed to do exactly what you need.
You may display whole document by:
$doc->saveHTML();
Or just certain node:
$doc->saveHTML( $bodyNode);
DOMDocument
also provides few options how to enhance how the XML is print, such as: