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
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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.