]> granicus.if.org Git - php/commitdiff
- added method DomNode->remove_child()
authorUwe Steinmann <steinm@php.net>
Fri, 12 Apr 2002 13:23:07 +0000 (13:23 +0000)
committerUwe Steinmann <steinm@php.net>
Fri, 12 Apr 2002 13:23:07 +0000 (13:23 +0000)
ext/domxml/php_domxml.c
ext/domxml/php_domxml.h

index 8ae4d6941a7cda7e92d564745c60101648033017..f331e6e272c7840a3d6b560eb51f5187f85265df 100644 (file)
@@ -318,7 +318,6 @@ static zend_function_entry php_domxmlnode_class_functions[] = {
        PHP_FALIAS(node_value,                          domxml_node_value,                              NULL)
        PHP_FALIAS(first_child,                         domxml_node_first_child,                NULL)
        PHP_FALIAS(last_child,                          domxml_node_last_child,                 NULL)
-       PHP_FALIAS(add_child,                           domxml_node_add_child,                  NULL)
        PHP_FALIAS(children,                            domxml_node_children,                   NULL)
        PHP_FALIAS(child_nodes,                         domxml_node_children,                   NULL)
        PHP_FALIAS(previous_sibling,            domxml_node_previous_sibling,   NULL)
@@ -328,6 +327,7 @@ static zend_function_entry php_domxmlnode_class_functions[] = {
        PHP_FALIAS(parent_node,                         domxml_node_parent,                             NULL)
        PHP_FALIAS(insert_before,                       domxml_node_insert_before,              NULL)
        PHP_FALIAS(append_child,                        domxml_node_append_child,               NULL)
+       PHP_FALIAS(remove_child,                        domxml_node_remove_child,               NULL)
        PHP_FALIAS(owner_document,                      domxml_node_owner_document,             NULL)
        PHP_FALIAS(new_child,                           domxml_node_new_child,                  NULL)
        PHP_FALIAS(attributes,                          domxml_node_attributes,                 NULL)
@@ -335,6 +335,7 @@ static zend_function_entry php_domxmlnode_class_functions[] = {
        PHP_FALIAS(prefix,                                      domxml_node_prefix,                             NULL)
        PHP_FALIAS(clone_node,                          domxml_clone_node,                              NULL)
 /* Non DOM functions start here */
+       PHP_FALIAS(add_child,                           domxml_node_add_child,                  NULL)
        PHP_FALIAS(node,                                        domxml_node,                                    NULL)
        PHP_FALIAS(unlink,                                      domxml_node_unlink_node,                NULL)
        PHP_FALIAS(unlink_node,                         domxml_node_unlink_node,                NULL)
@@ -2090,6 +2091,40 @@ PHP_FUNCTION(domxml_node_insert_before)
 }
 /* }}} */
 
+/* {{{ proto object domxml_node_remove_child(object domnode)
+   Removes node from list of children */
+PHP_FUNCTION(domxml_node_remove_child)
+{
+       zval *id, *node;
+       xmlNodePtr children, child, nodep;
+       int ret;
+
+       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) {
+               return;
+       }
+
+       DOMXML_GET_OBJ(child, node, le_domxmlnodep);
+
+       children = nodep->children;
+       if (!children) {
+               RETURN_FALSE;
+       }
+
+       while (children) {
+               if (children == child) {
+                       zval *rv;
+                       xmlUnlinkNode(child);
+                       DOMXML_RET_OBJ(rv, child, &ret);
+                       return;
+               }
+               children = children->next;
+       }
+       RETURN_FALSE
+}
+/* }}} */
+
 /* {{{ proto bool domxml_node_set_name(string name)
    Sets name of a node */
 PHP_FUNCTION(domxml_node_set_name)
index 56e8d8aca45af11e07cd4b9fcccbe0f4da44e730..b48374a4309f2e11f8d1dd662cc079c75e3915c0 100644 (file)
@@ -109,6 +109,7 @@ PHP_FUNCTION(domxml_node_previous_sibling);
 PHP_FUNCTION(domxml_node_owner_document);
 PHP_FUNCTION(domxml_node_insert_before);
 PHP_FUNCTION(domxml_node_append_child);
+PHP_FUNCTION(domxml_node_remove_child);
 PHP_FUNCTION(domxml_node_add_child);
 PHP_FUNCTION(domxml_node_has_attributes);
 PHP_FUNCTION(domxml_node_has_child_nodes);