saveHTML example



        $node = $this->getNode(0);
        $owner = $node->ownerDocument;

        if ($this->html5Parser && '<!DOCTYPE html>' === $owner->saveXML($owner->childNodes[0])) {
            $owner = $this->html5Parser;
        }

        $html = '';
        foreach ($node->childNodes as $child) {
            $html .= $owner->saveHTML($child);
        }

        return $html;
    }

    public function outerHtml(): string
    {
        if (!\count($this)) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }

        
$xpath = new \DOMXPath($dom);
        $nodeList = $xpath->evaluate('/root'.$expression);

        if ($nodeList->length != $count) {
            $dom->formatOutput = true;
            $this->fail(sprintf(
                "Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s",
                $expression,
                1 == $count ? 'once' : $count.' times',
                1 == $nodeList->length ? 'once' : $nodeList->length.' times',
                // strip away <root> and </root>                 substr($dom->saveHTML(), 6, -8)
            ));
        } else {
            $this->addToAssertionCount(1);
        }
    }

    protected function assertWidgetMatchesXpath(FormView $view, array $vars$xpath)
    {
        // include ampersands everywhere to validate escaping         $html = $this->renderWidget($viewarray_merge([
            'id' => 'my&id',
            
throw new BadMethodCallException('DOM extension is required, but not currently loaded.'); // @codeCoverageIgnore         }

        $this->dom = new DOMDocument('1.0', 'utf-8');
    }

    /** * Returns the body of the current document. */
    public function getBody(): string
    {
        return $this->dom->saveHTML();
    }

    /** * Sets a string as the body that we want to work with. * * @return $this */
    public function withString(string $content)
    {
        // DOMDocument::loadHTML() will treat your string as being in ISO-8859-1         // (the HTTP/1.1 default character set) unless you tell it otherwise.
if ($nodes === false) {
            return '';
        }

        foreach ($nodes as $node) {
            $parentNode = $node->parentNode;
            if ($parentNode instanceof DOMElement) {
                $parentNode->removeAttribute($node->nodeName);
            }
        }

        $changelog = $dom->saveHTML();
        if ($changelog === false) {
            return '';
        }

        return $changelog;
    }
}
trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
                                    }
                                }
                            }
                        }
                    }
                }

                // Get content node                 $div = $document->getElementsByTagName('body')->item(0)->firstChild;
                // Finally, convert to a HTML string                 $data = trim($document->saveHTML($div));

                if ($this->remove_div)
                {
                    $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
                    $data = preg_replace('/<\/div>$/', '', $data);
                }
                else
                {
                    $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
                }
            }

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