News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

David Sklar's Blog:
Speed - DOM traversal vs. XPath in PHP 5
February 23, 2006 @ 06:43:03

On his blog today, David Sklar has this new post that compares the speed of two methods of grabbing info from an XML document in PHP5 - DOM traversal versus XPath.

Needing to pick out some bits from a smallish (40 lines) XML document studded with namespaces, I first turned to DomXPath. Worked great, code's concise, XPath expression is simple. But I had the nagging thought that using DOM traversal functions should be faster.

The results from his test? The DOM traversal is about four times faster than using XPath to achieve the same thing.

That 4x speed multiple translates into about a half second to execute for the XPath code and about 0.13 seconds to execute for the DOM code when each is run 10,000 times. Since a typical use of this code will involve it running maybe 10 or 20 times during a request, I'm happy to sacrifice a few microseconds of processor time in exchange for simpler code.

0 comments voice your opinion now!
speed xml parse dom traversal xpath php5 speed xml parse dom traversal xpath php5


blog comments powered by Disqus

Similar Posts

Travis Swicegood: Fluent-API, here I come!

NETTUTS.com: How to Build a Super Duper News Scroller

Henri Bergius' Blog: Next Midgard will be PHP5 only

DevShed: Parsing Child Nodes with the DOM XML extension in PHP 5

Brian DeShong's Blog: Small news that's big to me: my PHP Testfest submissions made it into 5_3!


Community Events





Don't see your event here?
Let us know!


developer laravel release api framework series library language symfony tips podcast community list introduction bugfix conference zendserver interview deployment voicesoftheelephpant

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework