You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Permutation of namespace prefixes but correctly assigned namespaces uris leads to unparsing the xpath.
The problem is that it was permuted same prefixes as are in the parse xml - situation 2
PHP Version
PHP 8.3.14 (cli) (built: Nov 19 2024 15:53:36) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.14, Copyright (c) Zend Technologies
with Zend OPcache v8.3.14, Copyright (c), by Zend Technologies
with Xdebug v3.4.1, Copyright (c) 2002-2025, by Derick Rethans
Operating System
Windows 11
The text was updated successfully, but these errors were encountered:
The $registerNodeNS argument is by default true, and that means it'll automatically register the node namespaces from the document. That means that the xpath evaluator will first try to use the ns2 and ns3 namespaces from the document itself when matching a node, if those namespaces are in scope. If they're not in scope, only then will your overrides (via registerNamespace) be used.
So to make your example work: either you always use the ns2 and ns3 namespaces from the document and remove the calls to registerNamespace. Or you make sure that $registerNodeNS is false such that your overrides are always used.
Quite unexpected behavior. The call to registerNamespace should override the namespaces picked up from the XML document. Perhaps the second parameter shouldn't have a default value - leaving it unset should be marked as deprecated.
Anyway, thanks for the clarification!
Description
The following code:
Resulted in this output:
But I expected this output instead:
Permutation of namespace prefixes but correctly assigned namespaces uris leads to unparsing the xpath.
The problem is that it was permuted same prefixes as are in the parse xml - situation 2
PHP Version
Operating System
Windows 11
The text was updated successfully, but these errors were encountered: