cvs: /php4/ext/domxml domxml.c

From: Date: Tue, 22 Feb 2000 17:03:31 +0000
Subject: cvs: /php4/ext/domxml domxml.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-10650@lists.php.net to get a copy of this message
steinm Tue Feb 22 09:03:31 2000 EDT Modified files: /php4/ext/domxml domxml.c Log: - dom tree isn't editable anymore. Will probably change back in the future Index: php4/ext/domxml/domxml.c diff -u php4/ext/domxml/domxml.c:1.17 php4/ext/domxml/domxml.c:1.18 --- php4/ext/domxml/domxml.c:1.17 Sat Feb 19 15:21:27 2000 +++ php4/ext/domxml/domxml.c Tue Feb 22 09:03:01 2000 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: domxml.c,v 1.17 2000/02/19 23:21:27 zeev Exp $ */ +/* $Id: domxml.c,v 1.18 2000/02/22 17:03:01 steinm Exp $ */ #include "php.h" @@ -884,6 +884,7 @@ Returns list of children nodes */ static int node_attributes(zval **attributes, xmlNode *nodep) { + zval *children; xmlAttr *attr; int ret; @@ -902,14 +903,18 @@ while(attr) { zval *pattr; MAKE_STD_ZVAL(pattr); - ret = zend_list_insert(attr, le_domxmlattrp); +// ret = zend_list_insert(attr, le_domxmlattrp); /* construct an object with some methods */ object_init_ex(pattr, domxmlattr_class_entry_ptr); - add_property_resource(pattr, "attribute", ret); +// add_property_resource(pattr, "attribute", ret); add_property_stringl(pattr, "name", (char *) attr->name, strlen(attr->name), 1); if(attr->val->content) add_property_stringl(pattr, "value", (char *) attr->val->content, strlen(attr->val->content), 1); + else if(attr->val->childs) { + if(0 == node_children(&children, attr)) + zend_hash_update(pattr->value.obj.properties, "children", strlen("children")+1, (void *) &children, sizeof(zval *), NULL); + } zend_hash_next_index_insert((*attributes)->value.ht, &pattr, sizeof(zval *), NULL); attr = attr->next; } @@ -941,14 +946,14 @@ /* Each child is a node object */ MAKE_STD_ZVAL(child); - ret = zend_list_insert(last, le_domxmlnodep); +// ret = zend_list_insert(last, le_domxmlnodep); /* construct a node object for each child */ object_init_ex(child, domxmlnode_class_entry_ptr); add_property_stringl(child, "name", (char *) last->name, strlen(last->name), 1); if(last->content) add_property_stringl(child, "content", (char *) last->content, strlen(last->content), 1); - add_property_resource(child, "node", ret); +// add_property_resource(child, "node", ret); add_property_long(child, "type", last->type); /* Add the node object to the array of children */ zend_hash_next_index_insert((*children)->value.ht, &child, sizeof(zval *), NULL); @@ -984,30 +989,31 @@ if (!docp) { RETURN_FALSE; } - ret = zend_list_insert(docp, le_domxmldocp); +// ret = zend_list_insert(docp, le_domxmldocp); /* construct the document is a php object for return */ object_init_ex(return_value, domxmldoc_class_entry_ptr); - add_property_resource(return_value, "doc", ret); +// add_property_resource(return_value, "doc", ret); add_property_stringl(return_value, "version", (char *) docp->version, strlen(docp->version), 1); zend_list_addref(ret); /* get the root and add as a property to the document */ root = docp->root; if (!root) { + xmlFreeDoc(docp); RETURN_FALSE; } - ret1 = zend_list_insert(root, le_domxmlnodep); -// add_property_resource(return_value, "root", ret1); +// ret1 = zend_list_insert(root, le_domxmlnodep); /* construct an object with some methods */ MAKE_STD_ZVAL(proot); object_init_ex(proot, domxmlnode_class_entry_ptr); - add_property_resource(proot, "node", ret1); +// add_property_resource(proot, "node", ret1); add_property_long(proot, "type", root->type); add_property_stringl(proot, "name", (char *) root->name, strlen(root->name), 1); if(root->content) add_property_stringl(proot, "content", (char *) root->content, strlen(root->content), 1); + /* Get the array of children of the root and add as property children */ if(0 == node_children(&children, root)) zend_hash_update(proot->value.obj.properties, "children", strlen("children")+1, (void *) &children, sizeof(zval *), NULL); @@ -1016,6 +1022,7 @@ zend_list_addref(ret1); /* add the new root object to the document */ zend_hash_update(return_value->value.obj.properties, "root", strlen("root")+1, (void *) &proot, sizeof(zval *), NULL); + xmlFreeDoc(docp); } /* }}} */

« previous php.version4 (#10650) next »