diff options
Diffstat (limited to 'ext/domxml/php_domxml.c')
| -rw-r--r-- | ext/domxml/php_domxml.c | 14 | 
1 files changed, 11 insertions, 3 deletions
| diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index 91bcb25e15..8262c1be38 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -3352,7 +3352,11 @@ PHP_FUNCTION(domxml_node_set_namespace)  	/* if node is in a document, search for an already existing namespace */  	if (nodep->doc != NULL) { -		nsptr = xmlSearchNsByHref(nodep->doc, nodep, (xmlChar*) uri); +		if (nodep->type == XML_ATTRIBUTE_NODE) { +			nsptr = xmlSearchNsByHref(nodep->doc, nodep->parent, (xmlChar*) uri); +		} else  { +			nsptr = xmlSearchNsByHref(nodep->doc, nodep, (xmlChar*) uri); +		}   	} else {  		nsptr = NULL;  	} @@ -3367,9 +3371,13 @@ PHP_FUNCTION(domxml_node_set_namespace)  			sprintf(prefixtmp, "a%d", random);  			prefix = prefixtmp;  		} -		nsptr = xmlNewNs(nodep, uri, prefix); +		if (nodep->type == XML_ATTRIBUTE_NODE) { +			nsptr = xmlNewNs(nodep->parent, uri, prefix); +		} else { +			nsptr = xmlNewNs(nodep, uri, prefix); +		}  	} -	 +  	xmlSetNs(nodep, nsptr);  }  /* }}} */ | 
