php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41175 SimpleXmlElement->addAttribute() doesn't allow empty strings
Submitted: 2007-04-24 10:22 UTC Modified: 2007-04-24 13:55 UTC
From: carl at thep dot lu dot se Assigned:
Status: Closed Package: SimpleXML related
PHP Version: 5.2.1 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: carl at thep dot lu dot se
New email:
PHP Version: OS:

 

 [2007-04-24 10:22 UTC] 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"/>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-24 13:55 UTC] iliaa@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 02:02:52 2024 UTC