PHP XML Benchmark

Interesting PHP benchmark of parsing XML showed up on PHP Everywhere. In High Speed XML Parsing is Not Intuitive, John Lim tested five methods of extracting the title element from an XML RSS feed. Surprising results; the regular expression match was by far the fastest, and I would have thought the SAX parsing (based on libxpat, I believe) would have scored significantly faster than the DOM or XPath parsing—but it came in last.

Of course, the regular expression matching in this case was a bit simplistic—typically if you’re going to parse XML files, you’re looking for more than one element. But it’s a good technique to keep in mind.