php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63503 DOMDocument::loadHTML prints warning while loading well-formed xhtml
Submitted: 2012-11-13 14:01 UTC Modified: 2013-12-02 14:48 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: gdec at prz-rzeszow dot pl Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.4.8 OS: Linux fpm-fcgi
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gdec at prz-rzeszow dot pl
New email:
PHP Version: OS:

 

 [2012-11-13 14:01 UTC] gdec at prz-rzeszow dot pl
Description:
------------
Exact PHP version is 5.4.7.
In the sample code, the variable $html contains a valid xhtml document.
The method DOMDocument::loadHTML does not expect however the </br> closing tag.

Test script:
---------------
$html=<<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>test</title></head>
    <body><p> test<br></br>test</p></body>
</html>
EOD;
$dom = new DOMDocument();
$dom->loadHTML($html);

Expected result:
----------------
expected result: no warning should be printed.

Actual result:
--------------
<br />
<b>Warning</b>:  DOMDocument::loadHTML(): Unexpected end tag : br in Entity, line: 5 in <b>[...][...]</b> on line <b>10</b><br />

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-02 14:48 UTC] mike@php.net
-Status: Open +Status: Not a bug
 [2013-12-02 14:48 UTC] mike@php.net
The operation succeeds, so the warning is just informational.
If you don't want libxml warnings printed, use internal error handling.

This is libxml's behavior.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 05 22:01:35 2025 UTC