php minixml详解

yipeiwu_com6年前PHP代码库
使用方法如下,可以看到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="/zb_users/upload/202003/4txxn0yavcv.jpg" /> 
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.

相关文章

php serialize()与unserialize() 不完全研究

serialize()和unserialize()在php手册上的解释是: serialize — Generates a storable representation of a va...

深入理解PHP的远程多会话调试

深入理解PHP的远程多会话调试

一、背景介绍 本文主要给大家介绍了关于PHP远程多会话调试的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍: 解决什么问题:多个项目断点调试,www.mysit...

PHP基于双向链表与排序操作实现的会员排名功能示例

本文实例讲述了PHP基于双向链表与排序操作实现的会员排名功能。分享给大家供大家参考,具体如下: 双向链表也叫双链表,是链表的一种,它的每个数据结点中都有两个指针,分别指向直接后继和直接前...

解析PHP中VC6 X86和VC9 X86的区别及 Non Thread Safe的意思

PHP现在推出5.3.0版本了,不过下载的时候有几个不同版本选择。那就是VC6 X86和VC9 X86。首先我来解答: VC6是什么?VC6就是legacy Visual Studio...

php.ini save_handler 修改不生效的解决办法

php5.3.3以前php-fpm还没有被php收录,配置php基本都在php.ini里面,php5.3.3及以后,除了在php.ini配置以外,还可以在php-fpm.conf里面配置...