Posted on

PHP Pretty Print XML

I have been working on MoneyPress : Amazon Edition to get it updated for the latest API release and bring it into the Charleston Software Associates stable of products.  Along the way I found myself needing to debug the XML being returned from the Amazon Product API.   Here is a quick trick for doing that.

$returnedXML = $result['body']
$xmlDoc = DOMDocument::loadXML($result['body']);
print '<pre>' . htmlentities($xmlDoc->sveXML()).'</pre>';