parseXhtml example

/** * Parse string into DOMDocument object using HTML5 parser if the content is HTML5 and the library is available. * Use libxml parser otherwise. */
    private function parseHtmlString(string $content, string $charset): \DOMDocument
    {
        if ($this->canParseHtml5String($content)) {
            return $this->parseHtml5($content$charset);
        }

        return $this->parseXhtml($content$charset);
    }

    private function canParseHtml5String(string $content): bool
    {
        if (!$this->html5Parser) {
            return false;
        }

        if (false === ($pos = stripos($content, '<!doctype html>'))) {
            return false;
        }

        
Home | Imprint | This part of the site doesn't use cookies.