function sanitize_cdata2xhtml($cdata) { //Keep iframes $cdata = str_replace('</iframe>', ' </iframe>', $cdata); $config = array('bare' => true, 'indent' => false, 'output-xhtml' => true, 'input-encoding' => 'utf8', 'clean' => true, 'wrap' => 0, 'doctype' => 'strict', 'drop-empty-paras' => true, 'hide-endtags' => true, 'show-body-only' => true, 'quote-ampersand' => true, 'quote-nbsp' => true); $tidy = new tidy(); $tidy->parseString($cdata, $config, 'utf8'); $tidy->CleanRepair(); $pattern = '/(<\\?xml)(.*)(\\/\\?>)/i'; $replacement = ''; $cleanxml = preg_replace($pattern, $replacement, $tidy->value); $pattern = '/(([ ]*)class="MsoNormal c[0-9]")/i'; $replacement = ''; $no_mso = preg_replace($pattern, $replacement, $cleanxml); return xmlEntities($no_mso); }