/**
  * Sets the parent node of this XmlNode.
  *
  * @access public
  */
 function setParent(&$parent)
 {
     if (strtolower(get_class($this)) == 'xml') {
         return;
     }
     if (isset($this->__parent) && is_object($this->__parent)) {
         if ($this->__parent->compare($parent)) {
             return;
         }
         foreach ($this->__parent->children as $i => $child) {
             if ($this->compare($child)) {
                 array_splice($this->__parent->children, $i, 1);
                 break;
             }
         }
     }
     if ($parent == null) {
         unset($this->__parent);
     } else {
         $parent->children[] =& $this;
         $this->__parent =& $parent;
     }
 }