ID:               41634
 Updated by:       [EMAIL PROTECTED]
 Reported By:      evan dot kaufman at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         DOM XML related
 Operating System: Mac OS X
 PHP Version:      5.2.3
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

createElement, by the spec, only accepts 1 argument and creates an
element node (no content - behavior you see not passing in argument).
When you pass in the second arg (which the binding allows by expanding
upon the spec, you are thereby asking for text node to be created within
the element and and thus if empty produces open and close tag.

If you don't want that then don't pass 2nd (optional) arg.


Previous Comments:
------------------------------------------------------------------------

[2007-06-08 14:20:53] evan dot kaufman at gmail dot com

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 this bug report at http://bugs.php.net/?id=41634&edit=1

Reply via email to