ID: 41326
Updated by: [EMAIL PROTECTED]
Reported By: php-bugs-0705 at nico dot edtinger dot at
Status: Closed
Bug Type: Feature/Change Request
Operating System: irrelevant
PHP Version: 5CVS-2007-05-08 (snap)
Assigned To: pajoye
New Comment:
Little notice about the final fix, there is now three cases:
$xml->writeElement('foo', '');
<foo></foo>
$xml->writeElement('foo', null);
<foo/>
$xml->writeElement('foo');
<foo/>
Doing it this way preserves BC while allowing the short form.
Previous Comments:
------------------------------------------------------------------------
[2007-05-08 21:42:50] [EMAIL PROTECTED]
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2007-05-08 15:31:35] php-bugs-0705 at nico dot edtinger dot at
Description:
------------
Currently Xmlwriter::WriteElement() and Xmlwriter::WriteElementNS()
require the forth argument $content and are therefor not able to output
empty tags. Someone has to use XmlWriter::startElement(); and
XmlWriter::endElement(); to output an empty tag. That's a bit
cumbersome.
It would be nice if $content could be made optional or set to null to
output an empty tag. I know it's the documented behavior, that it always
write a a full element tag and libxml2 does have the same behavior.
Nevertheless it would be a nice addition to be able to write less code
for a short tag.
Reproduce code:
---------------
<?php
$xml = new XmlWriter();
$xml->openMemory();
$xml->startDocument();
$xml->startElement('test');
$xml->writeElement('foo', null);
$xml->startElement('bar');
$xml->endElement('bar');
$xml->endElement();
echo $xml->outputMemory();
?>
Expected result:
----------------
<?xml version="1.0"?>
<test><foo/><bar/></test>
Actual result:
--------------
<?xml version="1.0"?>
<test><foo></foo><bar/></test>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41326&edit=1