DOMDocument::loadHTML(): Tag article invalid in Entity
Encountering unexpected error while parsing HTML5 tags:
DOMDocument::loadHTML(): Tag article invalid in Entity, line: 7
D:\...\Pasap\vendor\wa72\html-pretty-min\PrettyMin.php:76
Here is the code I'm trying to minify, https://validator.w3.org says it's valid:
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Document</title>
</head>
<body>
<article class="News"> <!-- It blocks here -->
<h1 class="title">We are Amazing</h1>
<div class="about">
<em>
By Me,
At 12-12-12 </em>
</div>
<div class="content">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Atque, consequatur cum iste laudantium libero magni maxime
minima mollitia quos. At earum nostrum pariatur. Amet, at
fugiat incidunt officia possimus vel?
</p>
</div>
</article>
</body>
</html>
It seems to be a known problem: http://stackoverflow.com/questions/6090667/php-domdocument-errors-warnings-on-html5-tags
$dom = new domDocument; libxml_use_internal_errors(true); // load the html into the object $dom->loadHTML($url);
@$dom->loadHTML($url); works for me
@$dom->loadHTML($url); works for me
why does this work?
can somebody explain what that @ does at the beginning of the line, and why the downvotes?
@ will disable error reporting
@$dom->loadHTML($url); works for me
why does this work? can somebody explain what that
@does at the beginning of the line, and why the downvotes?
hides errors and super not recommended
In PHP the @ symbol ignores error. See
https://www.php.net/manual/en/language.operators.errorcontrol.php
$dom->loadHtml($id);
work for me ( in Laravel 8.*)
HTML5 is not supported by libxml2, therefore any HTML5 tag will fail.
You can use (Since Libxml 2.6.0) the LIBXML_NOERROR flag to not get these errors, but in any way when you disable error reporting or suppress it, you will not receive errors for malformatted content.
$dom->loadHtml($id, LIBXML_NOERROR);
HTML5 is not supported by libxml2, therefore any HTML5 tag will fail. You can use (Since Libxml 2.6.0) the
LIBXML_NOERRORflag to not get these errors, but in any way when you disable error reporting or suppress it, you will not receive errors for malformatted content.$dom->loadHtml($id, LIBXML_NOERROR);
Thanks, work for me!