summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stocker <chregu@php.net>2004-07-25 11:02:43 +0000
committerChristian Stocker <chregu@php.net>2004-07-25 11:02:43 +0000
commit0b244def73779946d220161100392976fdc8241c (patch)
treed1745076436641440b697e89592891673f0eda37
parenta497e9bf75511e4a50f4a0541eae02bd215533f5 (diff)
downloadphp-git-0b244def73779946d220161100392976fdc8241c.tar.gz
added new method SimpleXMLElement->registerNamespace(string prefix, string uri)
"registers a prefix <-> namespaceURI combination for use in a later xpath query. "
-rw-r--r--NEWS1
-rw-r--r--ext/simplexml/simplexml.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 6da907236c..7a48461c75 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ PHP NEWS
. array_intersect_ukey() (Christiano Duarte)
. stream_context_get_default() (Wez)
. stream_socket_enable_crypto() (Wez)
+ . SimpleXMLElement->registerNamespace() (Christian)
- PHP will now respect extension dependencies when initializing. (Wez)
- Added Cursor support for MySQL 5.0.x in mysqli (Georg)
- Added proxy support to ftp wrapper via http. (Sara)
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index b2af53d210..c5ec233a23 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -843,6 +843,29 @@ SXE_METHOD(xpath)
xmlXPathFreeObject(retval);
}
+
+SXE_METHOD(registerNamespace)
+{
+ php_sxe_object *sxe;
+ zval *id;
+ int prefix_len, ns_uri_len;
+ char *prefix, *ns_uri;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &prefix, &prefix_len, &ns_uri, &ns_uri_len) == FAILURE) {
+ return;
+ }
+
+ sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+ if (!sxe->xpath) {
+ sxe->xpath = xmlXPathNewContext((xmlDocPtr) sxe->document->ptr);
+ }
+
+ if (xmlXPathRegisterNs(sxe->xpath, prefix, ns_uri) != 0) {
+ RETURN_FALSE
+ }
+ RETURN_TRUE;
+}
+
/* }}} */
/* {{{ proto asXML([string filename])
@@ -1604,6 +1627,7 @@ static zend_function_entry sxe_functions[] = {
SXE_ME(__construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) /* must be called */
SXE_ME(asXML, NULL, ZEND_ACC_PUBLIC)
SXE_ME(xpath, NULL, ZEND_ACC_PUBLIC)
+ SXE_ME(registerNamespace, NULL, ZEND_ACC_PUBLIC)
SXE_ME(attributes, NULL, ZEND_ACC_PUBLIC)
SXE_ME(children, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}