Need to manipulate XML document trees, but don't have the DOM extension compiled into your PHP build? Take a look at XMLTree, a PEAR class that allows you to create and manipulate XML document trees without requiring the PHP DOM extension.
In addition to dynamically creating an XML document tree, XMLTree also allows you to read an existing tree into memory, via its getTreeFromFile() method. Consider the following XML file, named "me.xml":
Let's now read this into an XML document tree with the getTreeFromFile() method:
// include class
// instantiate object
= new XML_Tree("me.xml");
// read file contents
$root =& $tree->getTreeFromFile();
In this case, the getTreeFromFile() method has been used to read the contents
of the XML file specified in the object constructor, and convert it into an XMLTree object. The tree can then be viewed via a call to dump().
Take a quick peek at the object created by getTreeFromFile() with the print_r() function, and here's what you'll see: