Re: Planning to create Array -> XML extension
| From: | Andrey Hristov | Date: | Tue, 15 Jul 2008 11:04:02 +0000 |
| Subject: | Re: Planning to create Array -> XML extension | ||
| References: | 1 2 3 4 5 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-5622@lists.php.net to get a copy of this message | ||
Dmitry Koterov wrote:
Have you tried with recursive algorithm that instead of creating a string does output the text. Just prevent the output by enabling the output buffering. At the end just read the output buffer and clean it. Not sure if the ob subsystem if more efficient, this is just a hint to try something before starting C coding. Otherwise, you might implement StringBuffer class and still do the conversion in PHP userland. The Buffer will insternally use smart_str for example. Won't be hard to implement. AndreyI think, you will start to notice difference if arrays contain 1000+elements. Unfortunately, 100+. I suspect that PHP concatenation operator (".") is inefficient because of multiple memory reallocation and copy operations performed (there is no Java StringBuffer analog in PHP), so I am planning to perform thes operations in C memory "doubled-reallocation" algorythm. (Direct using of PHP's libxml's appendChild() via PHP calls is even slower, it's tested.) And the resulting XML may be about 300-400K (bad, but can't do anything with that, it's the legacy architecture issue). These 300K are parsed by libxslt in 2-3ms (very fast!), but generated from arrays for about 100-200ms in pure PHP (very slow). It's a real problem...There is a php extension to generate JSON and it should be no problem togo from JSON to XML in Java. The language is PHP, so I don't want to use Java. The processor is http://php.net/xsl