Converting XML Into a PHP Data Structure - Conclusion (Page 9 of 9 )
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.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.