rootNodes = array(); $this->currentNode = null; } function destroy() { unset($this->currentNode, $this->currentData, $this->rootNode); } /** * Callback function to act as the start element handler. * @param $parser XMLParser * @param $tag string * @param $attributes array */ function startElement($parser, $tag, $attributes) { $this->currentData = null; $node = new XMLNode($tag); $node->setAttributes($attributes); if (isset($this->currentNode)) { $this->currentNode->addChild($node); $node->setParent($this->currentNode); } else { $this->rootNode =& $node; } $this->currentNode =& $node; } /** * Callback function to act as the end element handler. * @param $parser XMLParser * @param $tag string */ function endElement($parser, $tag) { $this->currentNode->setValue($this->currentData); $this->currentNode =& $this->currentNode->getParent(); $this->currentData = null; } /** * Callback function to act as the character data handler. * @param $parser XMLParser * @param $data string */ function characterData($parser, $data) { $this->currentData .= $data; } /** * Returns a reference to the root node of the tree representing the document. * @return XMLNode */ function getResult() { return $this->rootNode; } } ?>