频道直达 - 学院 - 下载 - 交易 - 特效 - 字库 - 手册 -排名-工具- 繁體
网页教学网站开发 设为首页
加入收藏
联系我们
建站搜索: 常用广告代码   用户注册 | 用户登陆
您当前的位置:中国建站之家 -> 网站开发设计技术教程 -> PHP教程 -> 使用PHP 5.0 轻松解析XML文档3

使用PHP 5.0 轻松解析XML文档3

作者:aspcool  来源:aspcool  发布时间:2006-7-8 8:47:59  发布人:jz123

减小字体 增大字体

文件: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 pachage's 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 pachage's 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);

}

}

?>


将本文收藏到QQ书签与更多好友分享
[打 印]
[] [返回上一页] [收 藏]
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
精彩推荐
热门文章
· 注册码大全二
· 注册码大全四
· 注册码大全一
· 要10G免费网络硬盘的请进..
· 通过google 赶快来赚美金..
· 注册码大全十
· 头像-qq头像(qq新头像)4..
· 让你轻松架设FTP服务器1..
· 注册码大全三
· 梦幻背景图片7
· 卡通动物图片6
· 网页制作素材-按钮素材2..
· 让你轻松架设FTP服务器5..
· 风景图片8
· 注册码大全九
· 让你轻松架设FTP服务器2..
关注此文读者还看过
· 网站推广运营与系统正反..
· 雅虎通与MSN将互通 用户..
· 用Photoshop有效合成图像..
· 当当网俞渝披露她的生活..
· SQL Server数据库技术(..
· 论亮度的合并5
· PHPWind 5.0.1 安全补丁..
· 关于DNS服务器的配置问题..
· MySpace中国归属权之争
· RSA公钥密码体制安全性分..
· c#中使用自带的邮件发送..
· 做一个有责任的站长,关..
· 正则表达式系统教程(四)..
· “反转负冲”人像处理一..
· eBay改进德国网站 收费减..
· VBScript新手入门初学教..
相关文章
· 使用PHP的日期与时间函数提..
· 实用:使用PHP脚本修改Linu..
· 使用PHP开发网站过程中你注..
· 使用PHP脚本修改Linu..
· 使用PHP 5.0 轻松解析XML文..
· 使用PHP 5.0 轻松解析XML文..
· 使用PHP 5.0 轻松解析XML文..
· BS结构中使用PHP访问ORACLE..
· 如何使用PHP获取网络上文件..
· 使用PHP和XSL stylesheets转..
· 使用php+xslt在windows平台..
· 使用php4加速网络传输
· 使用PHP实现动态网页
· 使用PHP建立GIF
· 使用PHP3进行HTTP认证
· 使用php的编码功能-问题发现..
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 人才招聘
网站合作、内容监督、商务咨询:QQ: 9576619
Copyright ? 2005--2008 中国建站之家版权所有
粤ICP备05092265号