From:             evan dot kaufman at gmail dot com
Operating system: Mac OS X
PHP version:      5.2.3
PHP Bug Type:     DOM XML related
Bug description:  DOM XML tags with empty value generate different xml than 
tags with no value

Description:
------------
When a tag created with DOMDocument->createElement() is given *no* value,
its generated output (using DOMDocument->saveXML()) is a shortened
(self-closing) tag, but when it is given an *empty* value such as a blank
string or NULL, it displays as an expanded (opening and closing) tag.

Shouldn't any empty value be treated the same?  If anyone really wanted
expanded tags, they could use the already implemented LIBXML_NOEMPTYTAG
option, but there is no equivalent option to ask for shortened tags.

Reproduce code:
---------------
$doc1 = new DOMDocument();
$root1 = $doc1->createElement('root');
$doc1->appendChild($root1);
printf( "doc1: %s\n", $doc1->saveXML() );

$doc2 = new DOMDocument();
$root2 = $doc2->createElement('root', '');
$doc2->appendChild($root2);
printf( "doc2: %s\n", $doc2->saveXML() );

$doc3 = new DOMDocument();
$root3 = $doc3->createElement('root', NULL);
$doc3->appendChild($root3);
printf( "doc3: %s\n", $doc3->saveXML() );

Expected result:
----------------
doc1: <?xml version="1.0"?><root/>
doc2: <?xml version="1.0"?><root/>
doc3: <?xml version="1.0"?><root/>

Actual result:
--------------
doc1: <?xml version="1.0"?><root/>
doc2: <?xml version="1.0"?><root></root>
doc3: <?xml version="1.0"?><root></root>

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

Reply via email to