Categories

How to parse large sized XML files using PHP XML Parser

TweetShare(function() {var s = document.createElement(‘SCRIPT’), s1 = document.getElementsByTagName(‘SCRIPT’)[0];s.type = ‘text/javascript’;s.async = true;s.src = ‘http://widgets.digg.com/buttons.js’;s1.parentNode.insertBefore(s, s1);})();

I was recently provided a Google Base XML file by a client to load on one of his websites. The size of the XML file was over 20MB.  The format of the XML file was as follows:

<?xml version=”1.0″?> <rss [...]

How to parse an XML file in PHP

TweetShare(function() {var s = document.createElement(‘SCRIPT’), s1 = document.getElementsByTagName(‘SCRIPT’)[0];s.type = ‘text/javascript’;s.async = true;s.src = ‘http://widgets.digg.com/buttons.js’;s1.parentNode.insertBefore(s, s1);})();

PHP offers a new and fast way to parse XML files. This approach makes it easier to parse very large XML files in a couple of seconds.

Here goes the code to parse a sample XML file. The XML in [...]