public static function prettyPrint($xmlString, $htmlDisplay = false) {

        // Create a nicely formatted version
        $doc = new \DOMDocument();
        $doc->loadXML($xmlString);
        $doc->preserveWhiteSpace = false;
        $doc->formatOutput = true;

        $prettyXML = $doc->saveXML();

        if ($htmlDisplay) $prettyXML = str_replace(array("<", ">", "\n", " "), array("&lt;", "&gt;", "<br>", "&nbsp;"), $prettyXML);

        return $prettyXML;
    }