From: Wez Furlong Date: Sun, 7 Dec 2003 11:32:40 +0000 (+0000) Subject: allow $node['not_yet_existing_attribute'] = $value; to work X-Git-Tag: php-5.0.0b3RC1~215 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a98892900b03f0849d56599853ca74318a09865d;p=php allow $node['not_yet_existing_attribute'] = $value; to work --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 1a21c14ca4..b003d47af3 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -333,7 +333,18 @@ next_iter: } else if (counter > 1) { php_error(E_WARNING, "Cannot assign to an array of nodes (duplicate subnodes or attr detected)\n"); } else { - php_error(E_WARNING, "Cannot create new atrribute\n"); + switch (Z_TYPE_P(value)) { + case IS_LONG: + case IS_BOOL: + case IS_DOUBLE: + case IS_NULL: + convert_to_string(value); + case IS_STRING: + newnode = (xmlNodePtr)xmlNewProp(node, name, Z_STRVAL_P(value)); + break; + default: + php_error(E_WARNING, "It is not yet possible to assign complex types to attributes"); + } } }