From: Marcus Boerger Date: Fri, 24 Feb 2006 15:49:13 +0000 (+0000) Subject: - Add ability to add new nodes via properties X-Git-Tag: RELEASE_1_2~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b13105ee4c9a41ab73ce1b304b80214cbf1cfefb;p=php - Add ability to add new nodes via properties --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 5c2ac62dcd..276bacb9fc 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -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)) {