com php-src: Implements feature 55218: ext/simplexml/simplexml.c
| From: | Stanislav Malyshev | Date: | Fri, 22 Jun 2012 02:34:46 +0000 |
| Subject: | com php-src: Implements feature 55218: ext/simplexml/simplexml.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-69533@lists.php.net to get a copy of this message | ||
Commit: f1ef8b327f44d05015ea3b67c2a354572b782c08
Author: Lonny Kapelushnik <lonnyk@gmail.com> Thu, 21 Jun 2012 22:34:46 -0400
Parents: 041dd77135c89af821b483a3c1f485bfaf6cfb50
Branches: PHP-5.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f1ef8b327f44d05015ea3b67c2a354572b782c08
Log:
Implements feature 55218
Allows you to recursively check namespaces under a child node
instead of from the root of the XML doc
Changed paths:
M ext/simplexml/simplexml.c
Diff:
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 455280f..7236b8a 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -1513,22 +1513,28 @@ static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlNodePtr
node,
}
/* }}} */
-/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursive])
+/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursive [, bool from_root])
Return all namespaces registered with document */
SXE_METHOD(getDocNamespaces)
{
- zend_bool recursive = 0;
+ zend_bool recursive = 0, from_root = 1;
php_sxe_object *sxe;
+ xmlNodePtr node;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &recursive) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bb", &recursive,
&from_root) == FAILURE) {
return;
}
array_init(return_value);
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+ if(from_root){
+ node = xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr);
+ }else{
+ GET_NODE(sxe, node);
+ }
- sxe_add_registered_namespaces(sxe, xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr),
recursive, return_value TSRMLS_CC);
+ sxe_add_registered_namespaces(sxe, node, recursive, return_value TSRMLS_CC);
}
/* }}} */
@@ -2518,6 +2524,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_getnamespaces, 0, 0, 0)
ZEND_ARG_INFO(0, recursve)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_getdocnamespaces, 0, 0, 0)
+ ZEND_ARG_INFO(0, recursve)
+ ZEND_ARG_INFO(0, from_root)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_children, 0, 0, 0)
ZEND_ARG_INFO(0, ns)
ZEND_ARG_INFO(0, is_prefix)
@@ -2586,7 +2597,7 @@ static const zend_function_entry sxe_functions[] = { /* {{{ */
SXE_ME(attributes, arginfo_simplexmlelement_children, ZEND_ACC_PUBLIC)
SXE_ME(children, arginfo_simplexmlelement_children, ZEND_ACC_PUBLIC)
SXE_ME(getNamespaces, arginfo_simplexmlelement_getnamespaces, ZEND_ACC_PUBLIC)
- SXE_ME(getDocNamespaces, arginfo_simplexmlelement_getnamespaces, ZEND_ACC_PUBLIC)
+ SXE_ME(getDocNamespaces, arginfo_simplexmlelement_getdocnamespaces, ZEND_ACC_PUBLIC)
SXE_ME(getName, arginfo_simplexmlelement__void, ZEND_ACC_PUBLIC)
SXE_ME(addChild, arginfo_simplexmlelement_addchild, ZEND_ACC_PUBLIC)
SXE_ME(addAttribute, arginfo_simplexmlelement_addchild, ZEND_ACC_PUBLIC)