summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stocker <chregu@php.net>2006-07-16 15:03:53 +0000
committerChristian Stocker <chregu@php.net>2006-07-16 15:03:53 +0000
commitdc8ba6f47595e5fa665a647f8919c07fb0b77a11 (patch)
tree95c6c7af156229f57ed66b2684c93755d5f98b18
parent17f6ae66cea47b0ef642f7e071dff22fbb35e20f (diff)
downloadphp-git-dc8ba6f47595e5fa665a647f8919c07fb0b77a11.tar.gz
Added DOMNode::getNodePath() for getting an XPath for a node.
-rw-r--r--NEWS1
-rw-r--r--ext/dom/dom_fe.h1
-rw-r--r--ext/dom/node.c30
3 files changed, 32 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 058630ec5b..4f89ff8b96 100644
--- a/NEWS
+++ b/NEWS
@@ -77,6 +77,7 @@ PHP NEWS
- Added pg_field_table() function. (Edin)
- Added SimpleXMLElement::saveXML() as an alias for SimpleXMLElement::asXML().
(Hannes)
+- Added DOMNode::getNodePath() for getting an XPath for a node. (Christian)
- Optimized zend_try/zend_catch macros by eliminating memcpy(3). (Dmitry)
- Optimized require_once() and include_once() by eliminating fopen(3)
diff --git a/ext/dom/dom_fe.h b/ext/dom/dom_fe.h
index 111f9e25f3..467fc323fd 100644
--- a/ext/dom/dom_fe.h
+++ b/ext/dom/dom_fe.h
@@ -167,6 +167,7 @@ PHP_FUNCTION(dom_node_set_user_data);
PHP_FUNCTION(dom_node_get_user_data);
PHP_METHOD(domnode, C14N);
PHP_METHOD(domnode, C14NFile);
+PHP_METHOD(domnode, getNodePath);
/* domnodelist methods */
PHP_FUNCTION(dom_nodelist_item);
diff --git a/ext/dom/node.c b/ext/dom/node.c
index 62073ad4d9..5ae4827901 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -53,6 +53,7 @@ zend_function_entry php_dom_node_class_functions[] = {
PHP_FALIAS(getFeature, dom_node_get_feature, NULL)
PHP_FALIAS(setUserData, dom_node_set_user_data, NULL)
PHP_FALIAS(getUserData, dom_node_get_user_data, NULL)
+ PHP_ME(domnode, getNodePath, NULL, ZEND_ACC_PUBLIC)
PHP_ME(domnode, C14N, NULL, ZEND_ACC_PUBLIC)
PHP_ME(domnode, C14NFile, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
@@ -1857,3 +1858,32 @@ PHP_METHOD(domnode, C14NFile)
}
#endif
+
+/* {{{ proto int DOMNode::getNodePath()
+ Gets an xpath for a node */
+
+PHP_METHOD(domnode, getNodePath)
+{
+ zval *id;
+ xmlNode *nodep;
+ dom_object *intern;
+ char *value;
+
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, dom_node_class_entry) == FAILURE) {
+ return;
+ }
+
+ DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
+
+ value = xmlGetNodePath(nodep);
+ if (value == NULL) {
+ RETURN_EMPTY_STRING();
+ } else {
+ RETVAL_STRING(value, 1);
+ xmlFree(value);
+ }
+
+
+}
+