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

Christian Stocker's Blog:
How to extend SimpleXML with Missing Functionality
Nov 01, 2005 @ 11:27:04

In this post on Christian Stocker's blog today, he gives a quick example of how to extend SimpleXML with some "missing functionality" that he's needed.

Ever thought SimpleXML is too simple? Did you know, you can easily extend the SimpleXMLElement class?

From Rob Richards on the PHP internals mailinglist: "This [getting name and type of a Node] can be done extending the SimpleXMLElement and the functions are a whole 1 line of user code".

Basically, it abuses the DOM XML's import ability to pull in a SimpleXML object and use the nodeName and nodeType on it to get the corresponding data. Simple? check. Useful? check. Something to add to the library? definitely...

tagged:

Link:


Trending Topics: