Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8358667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:52:22+00:00 2026-06-09T10:52:22+00:00

I run the code first on MAMP and it worked very well. But when

  • 0

I run the code first on MAMP and it worked very well. But when I tried to run the code on another server, I got a lot of warnings like:

Warning: DOMDocument::loadHTML(): Unexpected end tag : head in Entity,
line: 3349 in /cgihome/zhang1/html/cgi-bin/getPrice.php on line 17
Warning: DOMDocument::loadHTML(): htmlParseStartTag: misplaced tag in
Entity, line: 3350 in /cgihome/zhang1/html/cgi-bin/getPrice.php on
line 17 Warning: DOMDocument::loadHTML(): Tag header invalid in
Entity, line: 3517 in /cgihome/zhang1/html/cgi-bin/getPrice.php on
line 17

The codes are following:

<?php
 $amazon = file_get_contents('http://www.amazon.com/blablabla');
 $doc = new DOMdocument();
 $doc->loadHTML($amazon);
 $doc->saveHTML();
 $price = $doc -> getElementById('actualPriceValue')->textContent;
 $ASIN = $doc -> getElementById('ASIN')->getAttribute('value');
?>

Anyone knows what’s going on? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:52:26+00:00Added an answer on June 9, 2026 at 10:52 am

    To disable the warning, you can use

    libxml_use_internal_errors(true);
    

    This works for me, Manual, read on:


    Background: You are loading invalid HTML. Invalid HTML is quite common, DOMDocument::loadHTML corrects most of the problems, but gives warnings by default.

    With libxml_use_internal_errors you can control that behavior. Set it before loading the document:

    $previously = libxml_use_internal_errors(true);
    $doc->loadHTML($amazon);
    

    Then after loading you can deal with the errors (if you want/need to):

    /* @var LibXMLError[] $xmlErrors */
    $xmlErrors = libxml_get_errors();
    

    And finally clear them (as they will add up) and restore the previous setting if applicable:

    unset($xmlErrors);
    libxml_clear_errors();
    libxml_use_internal_errors($previously);
    

    References

    • libxml_use_internal_errors Disable libxml errors and allow user to fetch error information as needed
    • libxml_clear_errors Clear libxml error buffer
    • libxml_get_errors Retrieve array of errors
    • LibXMLError The libXMLError class
    • Stackoverflow answer to DOMDocument PHP Memory Leak (by Tak; Dec 2011)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to run the code from Head First Java as the following: public
When I run the first code and press ctrl-c immediately there will be no
when I run this code for the first time <?php session_start(); echo SID; ?>
I tried to run this code: #define ROW_CNT 8; #define COLUMN_CNT 24; #define FIRST_COLUMN
When I run the following code, it only seems to be downloading the first
I am trying to run code on several cores (I tried both the snow
I am using Code First Migrations Beta 1. I would like to see the
When I run my service I got exception: The server encountered an error processing
I am completely new to using code first for modeling databases. I've tried to
Trying to get my first MVC + EF code first project to run. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.