PHP:JSON或XML解析器更快吗? [英] PHP: is JSON or XML parser faster?

查看:111
本文介绍了PHP:JSON或XML解析器更快吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建与Twitter API交互的类,并且想知道PHP的内置XML或JSON解析器是否更快? Twitter会以两种格式向我发送相同的数据,因此PHP的性能将决定我的选择.我使用的是php_apc,因此您可以忽略解析时间,并假设我正在使用字节码.

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.

谢谢!

更多:我只是想从数据中获取关联数组.我不是在做树遍历,节点迭代或任何太复杂的事情.格式将始终相同. (我希望!)

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!)

推荐答案

我没有进行任何基准测试,但是...

I didn't do any benchmark but...

由于JSON只是对嵌套字符串序列的描述,而无需提供DOM接口,属性解析和其他细微内容,因此我猜测JSON解析器比XML解析器要快得多.

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.

这篇关于PHP:JSON或XML解析器更快吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆