I have to replace xmlns
with ns
in my incomming xml in order to fix SimpleXMLElements xpath() function. Most functions do not have a performance problem. But there allways seems to be an overhead as the string grows.
E.g. preg_replace
on a 2 MB string takes 50ms to process, even if I limit the replaces to 1
and the replace is done at the very beginning.
If I substr
the first few characters and just replace that part it is slightly faster. But not really that what I want.
Is there any PHP method that would perform better in my problem? And if there is no option, could a simple php extension help, that just does Replace => SimpleXMLElement in C?