parseHtmlString example


    public function addHtmlContent(string $content, string $charset = 'UTF-8')
    {
        $dom = $this->parseHtmlString($content$charset);
        $this->addDocument($dom);

        $base = $this->filterRelativeXPath('descendant-or-self::base')->extract(['href']);

        $baseHref = current($base);
        if (\count($base) && !empty($baseHref)) {
            if ($this->baseHref) {
                $linkNode = $dom->createElement('a');
                $linkNode->setAttribute('href', $baseHref);
                $link = new Link($linkNode$this->baseHref);
                $this->baseHref = $link->getUri();
            }
Home | Imprint | This part of the site doesn't use cookies.