- print_r: documentation ( source)
<?php
$xml = <<<XML
<html>
<head><HEADER/></head>
<body>
<ul>
<li><a href="page2">page2</a>
</li>
</ul>
<CONTENT/>
</body>
<FOOTER/>
</html>
XML;
$content = "<div id='main'>asdf asdf</div>";
$header = "<title>page 1</title>";
$footer = "<script type='text/javascript'></script>";
$doc = new DOMDocument();
$doc->loadXML($xml);
$xp = new DOMXPath($doc);
print_r($xp->evaluate("//HEADER | //CONTENT | //FOOTER"));
//$ctag->parentNode->replaceChild(new DOMCdataSection($content),$ctag);
echo $doc->saveHTML();