function parseHTML($html, $simplify = false) { // reads and echos HTML (text) ... simple? not so fast, this must validate to echo, so if the HTML is broken, it will echo what CAN be understood // returns false if unable to parse $xObj = new xmlHandler(); $html = $xObj->parseXML($html, array(C_XML_LAX => true, C_XML_REMOVECOMMENTS => true), false, true); // don't parse parameters, silent if ($html !== false) { $ok = $xObj->outputHTML($html, false, true, $simplify); unset($xObj); if ($ok !== false) { return $ok; } } else { unset($xObj); } return false; }