From:             tom at whyscream dot net
Operating system: Linux (gentoo)
PHP version:      5.0.3
PHP Bug Type:     DOM XML related
Bug description:  DomDocument::saveHTML() produces outdated HTML

Description:
------------
The HTML that is generated by DomDocument::saveHTML() (and probably
saveHTMLFile() too) does not validate as XHTML (as in '1.0 Transitional').
In stead it follows common practice for HTML4.
Since some time, it's Good Practice (TM) to use simple rules like:
- always give a value to an attribute
- close single-tag elements with a '/>' instead of '>'
 etc.

All common browsers understand this syntax, even when a HTML 4.0 DTD is
specified.

With the current implementation, it's impossible to create valid XHTML
(snippets) using the php5 DOM extension.

Reproduce code:
---------------
$doc = new DomDocument();
$input = $doc->createElement('input');
$input->setAttribute('type', 'checkbox');
$input->setAttribute('checked', 'checked');
$doc->appendChild($input);
echo $doc->saveHTML();

Expected result:
----------------
This should generate a string like:
<input type="checkbox" checked="checked" />
which is valid XHTML.

Actual result:
--------------
The generated string looks like this: 
<input type="checkbox" checked>
This code gives 2 parse errors:
- no value for attribute 'checked'
- end tag for 'input' omitted (i,e, missing the forward slash)

-- 
Edit bug report at http://bugs.php.net/?id=31130&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31130&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31130&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31130&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31130&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31130&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31130&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31130&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31130&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31130&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31130&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31130&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31130&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31130&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31130&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31130&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31130&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31130&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31130&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31130&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31130&r=mysqlcfg

Reply via email to