00001 <?php
00002
00018
00019
00020
00021 import('xml.XMLNode');
00022
00023 class XMLParserDOMHandler extends XMLParserHandler {
00024
00026 var $rootNode;
00027
00029 var $currentNode;
00030
00032 var $currentData;
00033
00037 function XMLParserHandler() {
00038 $this->rootNodes = array();
00039 $this->currentNode = null;
00040 }
00041
00045 function startElement(&$parser, $tag, $attributes) {
00046 $this->currentData = null;
00047 $node = &new XMLNode($tag);
00048 $node->setAttributes($attributes);
00049
00050 if ($this->currentNode != null) {
00051 $this->currentNode->addChild($node);
00052 $node->setParent($this->currentNode);
00053
00054 } else {
00055 $this->rootNode = &$node;
00056 }
00057
00058 $this->currentNode = &$node;
00059 }
00060
00064 function endElement(&$parser, $tag) {
00065 $this->currentNode->setValue($this->currentData);
00066 $this->currentNode = &$this->currentNode->getParent();
00067 $this->currentData = null;
00068 }
00069
00073 function characterData(&$parser, $data) {
00074 $this->currentData .= $data;
00075 }
00076
00081 function &getResult() {
00082 return $this->rootNode;
00083 }
00084
00085 }
00086
00087 ?>