当前位置: 首页 > 图文教程 > 网络编程 > PHP > php minixml详解

PHP
在PHP中使用模板的方法
php中iconv函数使用方法
谈谈新手如何学习PHP网络编程
JS实现php的伪分页
需要使用php模板的朋友必看的很多个顶级PHP模板引擎比较分析
五个PHP程序员工具
CodeIgniter php mvc框架 中国网站
php mysql数据库操作类
php MySQL与分页效率
WindowsXP中快速配置Apache+PHP5+Mysql
php创建多级目录代码
php中对xml读取的相关函数的介绍一
Excel数据导入Mysql数据库的实现代码
比较全的PHP 会话(session 时间设定)使用入门代码
快速配置PHPMyAdmin方法
MySQL数据源表结构图示
改变Apache端口等配置修改方法
PHP读取MySQL数据代码
详解PHP显示MySQL数据的三种方法
PHP中Date获取时间不正确怎么办

PHP 中的 php minixml详解


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 95 ::
收藏到网摘: n/a

MiniXML来自 Sourceforge ,参见:http://sourceforge.net/projects/minixml/,也有自己的官方网站: http://minixml.psychogenic.com/index.html. 使用方法如下,可以看到miniXML的使用,与ActiveLink-PHP-XML-Package-0.4.0相比,更加符合使用习惯,也更加的简单.
$xmlDoc = new MiniXMLDoc();
$xmlRoot =& $xmlDoc->getRoot();
$childElement =& $xmlRoot->createChild(\'achild\');
$childElement->attribute(\'name\', \'annie\');
$childElement->text(\'This element has attributes and children, such as this\');
$image =& $childElement->createChild(\'image\');
$image->attribute(\'location\', \'http://psychogenic.com/image.png\');
$childElement->text(\'image and little\');
$orphan =& $xmlDoc->createElement(\'song\');
$orphan->text(\'tomorrow, tomorrow\');
$childElement->appendChild($orphan);
print $xmlDoc->toString();
添加一个子元素,有两种方式,第一种是直接该结点createChild,第二种是先xmlDoc先createElement,然后,该结点在appendChild.
最后打印出来的结果是:
<?xml version="1.0"?>
<achild name="annie" eyes="#0000FF" hair="#FF0000">
This element has attributes and children, such as this
<image location="http://psychogenic.com/image.png" />
image and little
<song> tomorrow, tomorrow </song>
</achild>

可以很明显的看得出,miniXML的使用方法是非常简单的,尤其是对于简单的保存数据的XML文件,更是如此,详细可以看miniXML提供的例子.此处不详说.
=========================================================================
解析
minixml文件结构是:
minixml.inc.php
------classes
-----------doc.inc.php element.inc.php node.inc.php treecomp.inc.php
详细的API解释说明,在官方网站上有介绍: http://minixml.psychogenic.com/api.html.