]> granicus.if.org Git - php/commitdiff
- Add ability to add new nodes via properties
authorMarcus Boerger <helly@php.net>
Fri, 24 Feb 2006 15:49:13 +0000 (15:49 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 24 Feb 2006 15:49:13 +0000 (15:49 +0000)
ext/simplexml/simplexml.c

index 5c2ac62dcd532e5c4fc850869cf51829185d59eb..276bacb9fc3c043b6ceea6f3925aeaaaea824d75 100644 (file)
@@ -390,6 +390,7 @@ static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_boo
        char           *name;
        xmlNodePtr      node;
        xmlNodePtr      newnode = NULL;
+       xmlNodePtr      mynode;
        xmlNodePtr              tempnode;
        xmlAttrPtr      attr = NULL;
        int             counter = 0;
@@ -450,6 +451,8 @@ static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_boo
                test = 0;
        }
 
+       mynode = node;
+
        if (node) {
                if (attribs) {
                        if (Z_TYPE_P(member) == IS_LONG) {
@@ -510,6 +513,8 @@ next_iter:
                        change_node_zval(newnode, value TSRMLS_CC);
                } else if (counter > 1) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot assign to an array of nodes (duplicate subnodes or attr detected)");
+               } else if (elements && !node) {
+                       xmlNewChild(mynode, mynode->ns, name, Z_STRVAL_P(value));       
                } else {
                        if (attribs) {
                                switch (Z_TYPE_P(value)) {