PHP: is JSON or XML parser faster?

json, performance, php, xml

Solution

I didn't do any benchmark but...

Since JSON is only a description of nested string sequences, without the need to offer a DOM interface, attributes parsing and other subtle stuff, my guess is that a JSON parser is WAY faster that an XML parser.

Problem

I'm building classes that interface with the Twitter API, and I'm wondering whether PHP's built-in XML or JSON parser is faster? Twitter will send me the same data in either format, so PHP performance will determine my choice. I'm using php_apc, so you can disregard parse time and assume I'm running off bytecode. Thanks! more: I'm just looking to get associative arrays from the data. I'm not doing tree walking, node iteration or anything too complex. The format will always be the same. (I hope!)

Original source