在PHP中将大型XML文件转换为CSV [英] Convert large XML file to CSV in PHP

查看:81
本文介绍了在PHP中将大型XML文件转换为CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个50MB的XML文件。我想将其转换为CSV文件,但大多数方法我发现耗尽服务器内存。

I have a 50MB XML file. I want to convert it to a CSV file, but most methods I have found exhaust the server memory. Is there a good way to do this using a stream method such as XMLreader.

推荐答案

您想要使用 XmlReader 解析XML,因为它作为一个基于事件的解析器 - 例如。它不会将所有内容加载到内存中,而是在通过输入文件前进行读取。

You'd want to use XmlReader to parse the XML, as it works as an event based parser - Eg. it doesn't load everything into memory, but rather reads as it advances through the input file.

这篇关于在PHP中将大型XML文件转换为CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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