Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOMDocument::loadHTML(): Tag article invalid in Entity #1

Open
Odepax opened this issue Aug 4, 2016 · 9 comments
Open

DOMDocument::loadHTML(): Tag article invalid in Entity #1

Odepax opened this issue Aug 4, 2016 · 9 comments

Comments

@Odepax
Copy link

Odepax commented Aug 4, 2016

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

@behrouz-azand
Copy link

$dom = new domDocument;
libxml_use_internal_errors(true);
// load the html into the object
$dom->loadHTML($url);

@BERRAMOU
Copy link

@$dom->loadHTML($url);
works for me

@ecairol
Copy link

ecairol commented Feb 4, 2020

@$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?

@fri3ndly
Copy link

@ will disable error reporting

@marcaum54
Copy link

@$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

@tankfairies
Copy link

In PHP the @ symbol ignores error. See

https://www.php.net/manual/en/language.operators.errorcontrol.php

@webcomsco
Copy link

$dom->loadHtml($id);
work for me ( in Laravel 8.*)

@golddragon007
Copy link

golddragon007 commented Apr 11, 2022

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);

@ynfantes
Copy link

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);

Thanks, work for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants