如何使用 PHP 将大的 XML 文件拆分为较小的文件? [英] How can I split a big XML file into smallers with PHP?

查看:37
本文介绍了如何使用 PHP 将大的 XML 文件拆分为较小的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有超过 300 000 个条目的 XML 文件,我的脚本每天必须解析这些条目..

I have XML file with over 300 000 entries which my script has to parse each day..

xml 的结构如下:

<root>
     <item>
        <proper1></proper1>
        <proper2></proper2>
    </item>
</root>

我需要将大的 XML 文件拆分为较小的文件,以便我的 PHP 可以运行它们,目前它无法处理它,因为它使用了太多内存.任何人都可以帮助我吗?

I need to split the big XML file into smaller files so my PHP can run them, currently it cant proccess it because it uses too much memory. Can any one help me with that ?

推荐答案

请看这篇文章PHP XML 解析

  1. SAX 解析
  2. XML 阅读器 XMLReader 拉式解析器
  1. SAX parsing
  2. XML Reader XMLReader Pull Parser

最适合这份工作

阅读上面的文章,尝试一些代码,你一定会得到答案

Read the above article try some code with it you will definitely get the answer for this

这篇关于如何使用 PHP 将大的 XML 文件拆分为较小的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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