Jump to content

Simple way to parse LARGE XML files


sloth456

Recommended Posts

I have an xml file thats about 20MB, I want to parse it all into an array.  SimpleXML seems to have trouble processing it, I just get "Fatal error: Balloc() failed to allocate memory".

 

I've googled this topic and can't seem to find a straight forward solution.  There must be someone here who has had to do this before.

 

Is there an easy way to parse this?

Link to comment
https://forums.phpfreaks.com/topic/220243-simple-way-to-parse-large-xml-files/
Share on other sites

The XML Parser - http://us2.php.net/manual/en/book.xml.php allows you to parse an XML document line by line.

 

I do however recommend that you wrap the call-back functions in a OOP/Class so that you can share class variables as necessary between the call-back functions to 'remember' the present state/current tag name...

I really appreciate your input, I've seen this page before but I'm finding it really hard to understand.

 

Is there a good tutorial you can point me to?  Or even better, a ready made function/class?

 

Sorry to be such a noob, I'm finding this hard!

i agree with PFMaBiSmAd... the link provided has a lot of information if you sit down and read all of it... but you want something fast... so...

 

read the following links and you should get to where you'd like.

 

http://php.net/manual/en/ref.simplexml.php

 

this one will get you the tutorial that you are looking for

http://www.ibm.com/developerworks/library/x-pullparsingphp.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.