From a98892900b03f0849d56599853ca74318a09865d Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 7 Dec 2003 11:32:40 +0000 Subject: [PATCH] allow $node['not_yet_existing_attribute'] = $value; to work --- ext/simplexml/simplexml.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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"); + } } } -- 2.50.1