关于读大数据量的XML文件的读取问题

怪我咯
Release: 2017-04-07 11:31:36
Original
1985 people have browsed it

对于数据量较大的xml文件,使用xmlDocument读取时,虽然支持XPath,查询比较方便,但是需要先load,这样就浪费了内存,使用起来速度比较慢。

而如果使用XMLReader的话,不需要缓存,读取速度很快,但是如果要查询就不那么方便了,不支持XPath,只能通过Reader()方法前向循环。为了避免以上两种方法的缺点,想出以下方案:

1、先使用XMLReader将XML文件的内容读取到一个链表中。

2、查询的时候查询链表就可以了(可以在定义链表的类中定义查询函数,要查询的时候直接调用函数就可以了,非常方便)。

结果证明:速度和查询效果都很好。

The above is the detailed content of 关于读大数据量的XML文件的读取问题. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!