From: Uwe Steinmann Date: Fri, 12 Apr 2002 13:23:07 +0000 (+0000) Subject: - added method DomNode->remove_child() X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~694 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce00085cdd04698a81cbcb4c02dbeb6974c1a9f6;p=php - added method DomNode->remove_child() --- diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index 8ae4d6941a..f331e6e272 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -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) diff --git a/ext/domxml/php_domxml.h b/ext/domxml/php_domxml.h index 56e8d8aca4..b48374a430 100644 --- a/ext/domxml/php_domxml.h +++ b/ext/domxml/php_domxml.h @@ -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);