News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Christian Schaefer's Blog:
Simply iterate over XML with plain PHP using little memory and CPU
March 10, 2011 @ 08:11:31

In a new post to his Test.ical.ly blog Christian Schaefer shows you how to iterate over XML in a more efficient way with the help of the XMLReader and Iterator features that come with PHP.

One of the things I have been working on lately was a simple XML parser. It's a simple XML structure in my case though it could be more complex without much change. My solution was a quite powerful yet simple combination of XMLReader and the Iterator interface.

He includes a sample XML document similar to the one he was working with and shows how XMLReader can handle it, keeping only the currently needed information in memory at one time. His sample class (CustomXml) loads the file and defines all of the iterator methods to work with the data like "next", "prev" and "rewind".

0 comments voice your opinion now!
iterate xml xmlreader iterator memory tutorial


blog comments powered by Disqus

Similar Posts

Tiger Heron Blog: First steps with PHP - booting a script, Part 1

Nadeau Software: PHP tip: How to get a web page using CURL

Binary Tides Blog: Setup Apache 2.4 and Php FPM with mod proxy fcgi on Ubuntu 13.10

Docnet.nu: SSL And PHP Streams - Part 1: You Are Doing It Wrong™

IBM developerWorks: Understanding the Zend Framework,Part 4: When there is no feed, Zend_HTTP_Client


Community Events





Don't see your event here?
Let us know!


series library install release developer laravel podcast api symfony interview introduction wordpress configure threedevsandamaybe language list bugfix community application code

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework