Jump to content

Parse large XML files


gebeer
 Share

Recommended Posts

Hi,

just wanted to share something I came across while working on an import module for XML data from a web service. The XML I got was not huge, but still, loading around 3.5 MB of XML with 250+ large child nodes into memory at once with simplexml_load_file() and then looping over it had significant impact on performance.

I searched for a solution and found this great article about how to parse large XML files.

It basically explains how to utilize the native XMLReader class together with SimpleXMLElement to handle such situations in a memory efficient way.

After implementing it I got a significant improval on perceived performance. No comparison in numbers to share here as I'm a bit short on time.

  • Like 14
Link to comment
Share on other sites

 Share

×
×
  • Create New...