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.
XMLTree doesn't just restrict you to XML elements - you can easily add attributes to any element as well, simply by specifying them as an associative array of name-value pairs in your calls to the addRoot() or addChild() methods. Here's an example,
<?php
// include class
include("XML/Tree.php");
// instantiate object
$tree
= new XML_Tree();
// add the root element
$root =& $tree->addRoot("superhero",
NULL, array("owner" => "Marvel
Comics"));
// add child elements
$name =&
$root->addChild("name", "Peter Parker aka Spiderman"); $age =&
$root->addChild("age",
21); $sex =& $root->addChild("sex", "male");
$location =& $root->addChild("location",
"Manhattan");
// print tree
$tree->dump();
?>