#native_company# #native_desc#

Converting XML into a PHP data structure Page 10

By PHP Builder Staff
on December 25, 2002

In Summary

I use a version of this class to quickly import XML documents into a
multidimensional PHP array where I can then use PHP functions to manipulate
the array’s contents. You might be able to enhance this class speed-wise with
the use of references on your stack, or your might optimize by building a
Node class instead of using our simple Array.
The real purpose of this article is not just to give you a working PHP
class for XML, but rather to show you how you might develop your own
XML parsing class and toolset. There exist other PHP resources like
XPath that will allow you to search and extract values from XML documents
more quickly than through this method. Additionally, as the DOM parser
matures, you may find that it performs this parsing functionality for you
but with C code which is many times faster. For simple XML needs, however,
speed of execution is rarely the bottleneck for your application and this
approach is sufficient and sometimes even a ‘powerful’ solution for
getting the job done.