From: php-bugs-0705 at nico dot edtinger dot at Operating system: irrelevant PHP version: 5CVS-2007-05-08 (snap) PHP Bug Type: Feature/Change Request Bug description: Writing empty tags with Xmlwriter::WriteElement[ns]
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 bug report at http://bugs.php.net/?id=41326&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41326&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41326&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41326&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41326&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41326&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41326&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41326&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41326&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41326&r=support Expected behavior: http://bugs.php.net/fix.php?id=41326&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41326&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41326&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41326&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41326&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41326&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41326&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41326&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41326&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41326&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41326&r=mysqlcfg