How do I load a very large XML file in PHP?
-
I have a very large (90Mb) XML file and I can't get it's data any other way. I'm trying to load it in PHP but due to its size nothing will work. When loading it using DOMDocument, it just fails. Tried using simplexml_load_file as well but it threw a lot of "out of memory" errors. How else could I load it for processing? Cheers
-
Answer:
PHP has got a SAX parser for XML. SAX lets you chew the XML up bit at a time so you don't have a huge memory burden. Nowhere near as easy as simplexml but worth learning if you have outrageously big files. Or you can hack your PHP.INI if your web hosting allows you. You will find this line that you can change but don't complain to me if your server falls over. memory_limit = 16M ; Maximum amount of memory a script may consume (16MB)
Cam at Yahoo! Answers Visit the source
Related Q & A:
- How do I manipulate a large number of moving platforms?Best solution by Electrical Engineering
- How can I do a resource in PDF file?Best solution by Stack Overflow
- How can I make a dynamic web page in PHP?Best solution by Yahoo! Answers
- How can I parse a complex XML with PHP and CDATA?Best solution by Stack Overflow
- How do I save a large number of incoming e-mails to my computer in one go?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.