Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ public function xpath(string $expression): DOMNodeList
*/
public function html(): string
{
return trim(substr($this->document->saveHTML(), 23));
$html = $this->document->saveHTML();
$html = preg_replace('/^<\?xml[^>]*>\s*/i', '', $html);
$html = preg_replace('/^<!--.*?-->\s*/s', '', $html);

return trim($html);
}

/**
Expand Down