什么是PHP中最快的XML解析器? [英] What is the fastest XML parser in PHP?
问题描述
对于某个项目,我需要某种方式来解析XML并从中获取数据.所以我想知道,哪个内置解析器最快?
for a certain project, I need some way to parse XML and get data from it. So I wonder, which one of built-in parsers is the fastest?
此外,解析器可以接受XML字符串作为输入也很好-我有自己的线程安全处理文件的实现,并且我不希望某些讨厌的非线程安全的库做出自己的努力没有用的.
Also, it would be nice of the parser could accept a XML string as input - I have my own implementation of thread-safe working with files and I don't want some nasty non-thread-safe libraries to make my efforts useless.
推荐答案
最快的解析器将是SAX-不必创建dom,它可以使用部分xml或逐步地完成. PHP SAX解析器(Expat)的信息可以在此处找到.或者,有一个基于libxml的DOM解析器,名为SimpleXML .基于DOM的解析器将更易于使用,但通常要慢几个数量级.
The fastest parser will be SAX -- it doesn't have to create a dom, and it can be done with partial xml, or progressively. Info on the PHP SAX parser (Expat) can be found here. Alternatively there is a libxml based DOM parser named SimpleXML. A DOM based parser will be easier to work with but it is typically a few orders of magnitude slower.
这篇关于什么是PHP中最快的XML解析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!