]> granicus.if.org Git - php/commitdiff
allow $node['not_yet_existing_attribute'] = $value; to work
authorWez Furlong <wez@php.net>
Sun, 7 Dec 2003 11:32:40 +0000 (11:32 +0000)
committerWez Furlong <wez@php.net>
Sun, 7 Dec 2003 11:32:40 +0000 (11:32 +0000)
ext/simplexml/simplexml.c

index 1a21c14ca435efafc40c8bcc564b5584036e5e34..b003d47af338fa73b6531a0733019b6f077b8f30 100644 (file)
@@ -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");
+                       }
                }
        }