Title: PHP error &#8211; DOMDocument::loadHTML():
Last modified: November 20, 2020

---

# PHP error – DOMDocument::loadHTML():

 *  [tonyko33](https://wordpress.org/support/users/toniko33/)
 * (@toniko33)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/)
 * Hi !
 * I use your plugin and it works very well. I also use query monitor.
 * When I load my site with your plugin, query monitor reports a lot of PHP errors,
   whatever the page.
 * It displays the following message DOMDocument::loadHTML(): with for precision“
   Tag header” or “Tag nav” or “Tag path” (and many others) invalid in Entity ; 
   line …
 * The location seems the same for all the errors :
 *  wp-content/plugins/email-encoder-bundle/core/includes/classes/class-email-encoder-
   bundle-validate.php:378
    DOMDocument->loadHTML() wp-content/plugins/email-encoder-
   bundle/core/includes/classes/class-email-encoder-bundle-validate.php:378 Email_Encoder_Validate-
   >filter_soft_dom_attributes() wp-content/plugins/email-encoder-bundle/core/includes/
   classes/class-email-encoder-bundle-validate.php:62 Email_Encoder_Validate->filter_page()
   wp-content/plugins/email-encoder-bundle/core/includes/classes/class-email-encoder-
   bundle-run.php:305 Email_Encoder_Run->filter_page() wp-includes/class-wp-hook.
   php:287 apply_filters(‘final_output’) wp-content/plugins/email-encoder-bundle/
   core/includes/classes/class-email-encoder-bundle-run.php:124 Email_Encoder_Run-
   >apply_content_filter() Unknown location ob_end_flush() wp-content/plugins/smart-
   slider-3/Nextend/WordPress/OutputBuffer.php:202 Nextend\W\OutputBuffer->closeOutputBuffers()
   wp-includes/class-wp-hook.php:287 do_action(‘shutdown’) wp-includes/load.php:
   1007 shutdown_action_hook() Unknown location
 * What does it mean ? Is that an error ine the source code ?
 * Thanks for reply.

Viewing 14 replies - 1 through 14 (of 14 total)

 *  [Ironikus](https://wordpress.org/support/users/ironikus/)
 * (@ironikus)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13690193)
 * Hey [@toniko33](https://wordpress.org/support/users/toniko33/) – thank you for
   reaching out!
    Can you please share the PHP version you use, as well as which
   version of our plugin? And does it appear on all of your sites or only on a specific
   one? Thank you already a lot!
 *  Thread Starter [tonyko33](https://wordpress.org/support/users/toniko33/)
 * (@toniko33)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13706400)
 * HI [@ironikus](https://wordpress.org/support/users/ironikus/) – thank you for
   answer.
 * My PHP version is 7.3.24.
    I use the free version of the plugin version 2.1.0.
   I have only one site. And it appears on all the pages (even those without email
   or phone number that I also protect with your plugin) of the site.
 * Thank you
 *  [Ironikus](https://wordpress.org/support/users/ironikus/)
 * (@ironikus)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13706513)
 * Hey [@toniko33](https://wordpress.org/support/users/toniko33/) – Thank you for
   coming back to me.
    I tried to replicate the issue, but without luck – the plugin
   just works fine from my end. I can also see a message within the log you sent
   me about the Smartslider plugin that closes an output buffer. To make sure it’s
   not related to any third-party plugin, can you please deactivate them and try
   if the issue continues to exist? Thank you already a lot.
 * If you want to fix that issue temporarily, you can also turn off the attribute
   validation within the advanced settings (**Email Encoder** -> **Advanced Settings**-
   > **Protect..** -> **html attributes without soft encoding.**)
 * Thank you already very much.
 *  Thread Starter [tonyko33](https://wordpress.org/support/users/toniko33/)
 * (@toniko33)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13707155)
 * Hi [@ironikus](https://wordpress.org/support/users/ironikus/) !
 * You are right. When i disable Smart slider, there is no issue !
 * Should i try your solution to fix the issue temporarly ?
 * Thank you !
 *  [Ramona](https://wordpress.org/support/users/nextend_ramona/)
 * (@nextend_ramona)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13707466)
 * Hi [@toniko33](https://wordpress.org/support/users/toniko33/)
 * I’m Ramona from Smart Slider 3. I was able to reproduce this problem and I reported
   it to our developers to look into. We’ll keep you posted.
 *  [Ramona](https://wordpress.org/support/users/nextend_ramona/)
 * (@nextend_ramona)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13708171)
 * Hi [@toniko33](https://wordpress.org/support/users/toniko33/)
 * Our developer checked the error, and here’s what he found. These errors you see
   are thrown by the `DOMDocument` class. They’re not caused by Smart Slider. The
   Smart Slider 3’s codes appear in the call stack because it closes the output 
   buffer, but that shouldn’t really be relevant to the DOMDocument errors.
 * We suspect the reason Query Monitor reports these problems is because Smart Slider
   closes the output buffers, not PHP, so Query Monitor can capture these messages.
 *  Thread Starter [tonyko33](https://wordpress.org/support/users/toniko33/)
 * (@toniko33)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13708968)
 * HI [@nextend_ramona](https://wordpress.org/support/users/nextend_ramona/)
 * Thank you for reply. Your plugin is so cool !
    What does it mean for me ? Should
   I do something ? Or finally these errors are not very important ?
 * [@ironikus](https://wordpress.org/support/users/ironikus/) should I apply your
   temporary solution as a permanent solution ? Or it’s not recommended.
 * Thank you both for the details
 *  [Ironikus](https://wordpress.org/support/users/ironikus/)
 * (@ironikus)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13709440)
 * Hey [@nextend_ramona](https://wordpress.org/support/users/nextend_ramona/) – 
   thank you for reaching out, as well as for all of your support and details.
    
   Since we are also buffering our output, Query Monitor should also throw the errors
   at this point. After investigating the issue, the only thing I can think of is
   a broken HTML that can’t be parsed using `DOMDocument` class. While parsing, 
   inline javascript that contains closing and opening tags, might break the logic
   since it doesn’t know that Javascript must be treated as a string, which leads
   to broken HTML entities that might cause this issue. Since you can reproduce 
   this issue: Can you please check if there are any scripts loaded that contain
   HTML tags within the inline scripts? In case there are, please also check if 
   they are written with `<!-- -->` and the beginning and end. This will tell the
   DOM handler not only to not validate tags within the string but also allows our
   Email Encoder (and every other browser) to encode HTML entities within the code.
 * [@toniko33](https://wordpress.org/support/users/toniko33/) – in regards to your
   question: Using the alternative fix, our email encoder will not soft-encode emails
   that occur within HTML attributes (e.g. `<div attribute="your@email.com">Some
   Text</div>`). – If you know you don’t use any plugin that adds emails as an attribute(
   except of mailto links), you are good to go. I suggest just deactivating it and
   taking a look if all sites are still looking great. If that’s the case, the temporary
   fix can be applied permanently.
 * If you have any further questions, please let me know.
 *  Thread Starter [tonyko33](https://wordpress.org/support/users/toniko33/)
 * (@toniko33)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13713049)
 * Hey [@ironikus](https://wordpress.org/support/users/ironikus/)
 * Thank you for support and help !
 * Unfortunately, whether I check or uncheck the option “html attributes without
   soft encoding” the problem stays the same.
 * For the moment and while waiting for [@nextend_ramona](https://wordpress.org/support/users/nextend_ramona/)
   to look at your request, it will remain like this.
 * Have a great day
 *  [Nextendweb](https://wordpress.org/support/users/nextendweb/)
 * (@nextendweb)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13716039)
 * Hi [@ironikus](https://wordpress.org/support/users/ironikus/), [@toniko33](https://wordpress.org/support/users/toniko33/),
   
   I checked this issue with WordPress 5.5.3 + Email Encoder 2.1.0 + Smart Slider
   + Query Monitor + Twenty Twenty theme.
 * The `DOMDocument` parser throws the warnings for the custom tags in this theme.
   If Smart Slider not activated, Query Monitor won’t show these errors as Email
   Encoder’s output buffer is closed after Query Monitor done with the processing.
   As Smart Slider closes the buffers, it results that the Email Encoder’s output
   processing happens right before Query Monitor, so it is able to inform you about
   these warnings.
 * In my opinion `DOMDocument` is not the right tool for this kind of use. As I 
   red, it do not properly support HTML5 for example. This is why it throws these
   errors for valid custom tags.
 * The minimal effort solution would be to disable the libxml’s internal error reporting
   while you processing the HTML. It will properly suppress these warnings.
 *     ```
       $dom = new DOMDocument();
       $internal_errors = libxml_use_internal_errors(true);
       @$dom->loadHTML($content);
       libxml_use_internal_errors($internal_errors);
       ```
   
 *  Thread Starter [tonyko33](https://wordpress.org/support/users/toniko33/)
 * (@toniko33)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13750942)
 * Hi [@nextendweb](https://wordpress.org/support/users/nextendweb/) [@ironikus](https://wordpress.org/support/users/ironikus/)
 * Sorry for the delay in answering.
    Thanks for the feedback. What this means to
   me. Sorry, I’m not a developer. Is it up to me to apply this patch? If so, how
   do I proceed ?
 * Thank you in advance
 *  [Ironikus](https://wordpress.org/support/users/ironikus/)
 * (@ironikus)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13756307)
 * Hey [@toniko33](https://wordpress.org/support/users/toniko33/) – thank you for
   coming back to me – I’m happy to inform you that we will correct this issue from
   our end. There’s no further steps you have to do from here.
 * [@nextendweb](https://wordpress.org/support/users/nextendweb/) – thank you for
   the detailed explanation – we will take care of it from our end.
 * If you should have further questions, feel free to reach out at any time.
 *  Thread Starter [tonyko33](https://wordpress.org/support/users/toniko33/)
 * (@toniko33)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13786506)
 * HI [@ironikus](https://wordpress.org/support/users/ironikus/)
 * Thanks for reply.
    Unfortunately, my issue is still there, with the same php 
   error message (the one I posted in my first message). Actually, this does not
   prevent the proper functioning of the site; but it still there.
 * Thank you for your involvement.
 *  [Ironikus](https://wordpress.org/support/users/ironikus/)
 * (@ironikus)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13805518)
 * Hey [@toniko33](https://wordpress.org/support/users/toniko33/) – Thank you for
   coming back to me. Due to the complexity of it, we haven’t just involved a temporary
   solution, but currently working on a full integration for HTML5.
    Please ignore
   the notices so far – you can expect a fix for that with our next version release.
   In case you have any further questions, feel free to reach out again.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘PHP error – DOMDocument::loadHTML():’ is closed to new replies.

 * ![](https://ps.w.org/email-encoder-bundle/assets/icon-256x256.png?rev=2056506)
 * [Email Encoder - Protect Email Addresses and Phone Numbers](https://wordpress.org/plugins/email-encoder-bundle/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/email-encoder-bundle/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/email-encoder-bundle/)
 * [Active Topics](https://wordpress.org/support/plugin/email-encoder-bundle/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/email-encoder-bundle/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/email-encoder-bundle/reviews/)

 * 14 replies
 * 4 participants
 * Last reply from: [Ironikus](https://wordpress.org/support/users/ironikus/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-domdocumentloadhtml/#post-13805518)
 * Status: not resolved