#41175 [Opn->Csd]: SimpleXmlElement->addAttribute() doesn't allow empty strings

From: Date: Tue, 24 Apr 2007 13:55:06 +0000
Subject: #41175 [Opn->Csd]: SimpleXmlElement->addAttribute() doesn't allow empty strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-111851@lists.php.net to get a copy of this message
ID: 41175 Updated by: iliaa@php.net Reported By: carl at thep dot lu dot se -Status: Open +Status: Closed Bug Type: SimpleXML related Operating System: Linux PHP Version: 5.2.1 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2007-04-24 10:22:05] carl at thep dot lu dot se Description: ------------ A call like addAttribute("attrname", "") results in "PHP Warning: SimpleXMLElement::addAttribute(): Attribute name and value are required". In addition to the warning, the attribute is discarded. Reproduce code: --------------- <?php $xml = new SimpleXmlElement("<img></img>"); $xml->addAttribute("src", "foo"); $xml->addAttribute("alt", ""); echo $xml->asXML()."\n"; ?> Expected result: ---------------- <?xml version="1.0"?> <img src="foo" alt=""/> Actual result: -------------- PHP Warning: SimpleXMLElement::addAttribute(): Attribute name and value are required in [...]/test.php on line 4 <?xml version="1.0"?> <img src="foo"/> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41175&edit=1

« previous php.bugs (#111851) next »