Re: [PHP] Why is XML parser so slow?

2001-07-31 Thread terry chay

No the XML parser is not slow at all. Especially since the only one 
available in PHP 3 would have to be expat base. Since expat is an event 
based parser and a very well coded one, you should be able to extract 
strings from the XML document very easily.

Note that there are some libraries out there which take an XML 
document and put it into a tree of objects. These might not be fast (I 
never tried them on PHP  4.0.4). The correct approach if you need to 
manipulate the whole XML data store at once is to use a DOM based parser. 
Since PHP 4.0.2 there has been a DOM based parser marked as experimental. 
The thing is highly unstable and the PHP functions are very buggy so 
you'll have to work around those bugs. Also, the functionality is very 
un-DOMlike and most of the useful method calls aren't implemented.

Oh yeah, the parser leaks memory too. Typically a DOM based parser 
will use about 1.5x as much memory as the actual XML file, this one seems 
to use many times more--an double again in size they introduced XPATH 
support (I think around PHP 4.04pl1 or so). Note that this isn't a true 
memory leak since all the memory gets returned the httpd and the next PHP 
processes when the application quits.

However it is quite fast. I built a production web application for my 
last company with it. Each process (of which 80 or so run simultaneously 
on each server during peak) uses 100k+ XML file as well as a bunch of 
smaller (5L) files and the only lag is that the fact that the PHP 
processes can get so large that the operating system (FreeBSD and Linux) 
will end up swapping.

Note that a properly coded event based parser (expat) will beat a DOM 
one almost every time if speed is an issue. Personally, unless you are 
working on a large data store, the DOM one should be good enough given 
that everything will have latency once it goes over the internet. In the 
case of very large data stores, I recommend you install a database that 
understands XML (Oracle, SQL Server, etc).

Hopefully someone will fix the DOM issues in PHP in the next couple 
releases.

Take care,

terry

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Why is XML parser so slow?

2001-07-26 Thread Verebes Gabor

Hi!
I am writing an XML parser.
It is working fine, but so slowly.
I use PHP 3.0.16, is it too old?
I'd like to parse many small XML string.
Can my problem be, that I creat the xml_parser evrey time?

I don't thik it is normal to wait 3 sec for parsing some (less than 20)
small XML strings.
(a few line each)

Thanks:
Gabor





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]