<?php/** *========================================================= * * @author hahawen(大龄青年) * @since 2004-12-04 * @copyright Copyright (c) 2004, NxCoder Group * *========================================================= *//** * abstract class SimpleDocumentBase * base class for xml file parse * all this pachage's is work for xml file, and method is action as DOM. * * 1\ add/update/remove data of xml file. * 2\ explode data to array. * 3\ rebuild xml file * * @package SmartWeb.common.xml * @abstract * @version 1.0 */abstract class SimpleDocumentBase{ private $nodeTag = null; private $attributes = array(); private $values = array(); private $nodes = array(); function __construct($nodeTag) { $this->nodeTag = $nodeTag; } public function getNodeTag() { return $this->nodeTag; } public function setValues($values){ $this->values = $values; } public function setValue($name, $value) { $this->values[$name] = $value; } public function getValue($name=null) { return $name==null? $this->values: $this->values[$name]; } public function removeValue($name) { unset($this->values["$name"]); } public function setAttributes($attributes){ $this->attributes = $attributes; } public function setAttribute($name, $value) { $this->attributes[$name] = $value; } public function getAttribute($name=null) { return $name==null? $this->attributes: $this->attributes[$name]; } public function removeAttribute($name) { unset($this->attributes["$name"]); } public function getNodesSize() { return sizeof($this->nodes); } protected function setNode($name, $nodeId) { $this->nodes[$name] = $nodeId; } public abstract function createNode($name, $attributes); public abstract function removeNode($name); public abstract function getNode($name=null); protected function getNodeId($name=null) { return $name==null? $this->nodes: $this->nodes[$name]; }