文件:simpledocumentroot.php
<?php
/**
*=========================================================
*
* @author hahawen(大龄青年)
* @since 2004-12-04
* @copyright copyright (c) 2004, nxcoder group
*
*=========================================================
*/
/**
* class simpledocumentroot
* xml root class, include values/attributes/subnodes.
* all this pachages is work for xml file, and method is action as dom.
*
* @package smartweb.common.xml
* @version 1.0
*/
class simpledocumentroot extends simpledocumentbase
{
private $prefixstr = <?xml version="1.0" encoding="utf-8" ?>;
private $nodelists = array();
function __construct($nodetag)
{
parent::__construct($nodetag);
}
public function createnodeobject($pnodeid, $name, $attributes)
{
$seq = sizeof($this->nodelists);
$tmpobject = new simpledocumentnode($this, $pnodeid, $name, $seq);
$tmpobject->setattributes($attributes);
$this->nodelists[$seq] = $tmpobject;
return $tmpobject;
}
public function removenodebyid($id)
{
if(sizeof($this->nodelists)==1)
$this->nodelists = array();
else
unset($this->nodelists[$id]);
}
public function getnodebyid($id)
{
return $this->nodelists[$id];
}
public function createnode($name, $attributes)
{
return $this->createnodebyname($this, $name, $attributes, -1);
}
public function removenode($name)
{
return $this->removenodebyname($this, $name);
}
public function getnode($name=null)
{
return $this->getnodebyname($this, $name);
}
public function getsavexml()
{
$prefixspace = "";
$str = $this->prefixstr."\r\n";
return $str.parent::getsavexml(0);
}
}
?>
|
文件:simpledocumentnode.php
<?php
/**
*=========================================================
*
* @author hahawen(大龄青年)
* @since 2004-12-04
* @copyright copyright (c) 2004, nxcoder group
*
*=========================================================
*/
/**
* class simpledocumentnode
* xml node class, include values/attributes/subnodes.
* all this pachages is work for xml file, and method is action as dom.
*
* @package smartweb.common.xml
* @version 1.0
*/
class simpledocumentnode extends simpledocumentbase
{
private $seq = null;
private $rootobject = null;
private $pnodeid = null;
function __construct($rootobject, $pnodeid, $nodetag, $seq)
{
parent::__construct($nodetag);
$this->rootobject = $rootobject;
$this->pnodeid = $pnodeid;
$this->seq = $seq;
}
public function getpnodeobject()
{
return ($this->pnodeid==-1)? $this->rootobject: $this->rootobject->getnodebyid($this->pnodeid);
}
public function getseq(){
return $this->seq;
}
public function createnode($name, $attributes)
{
return $this->createnodebyname($this->rootobject, $name, $attributes, $this->getseq());
}
public function removenode($name)
{
return $this->removenodebyname($this->rootobject, $name);
}
public function getnode($name=null)
{
return $this->getnodebyname($this->rootobject, $name);
}
}
?>
|
