php minixml详解

yipeiwu_com5年前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 CodeBase:将时间显示为&quot;刚刚&quot;&quot;n分钟/小时前&quot;的方法详解

在很多场合为了显示出信息的及时性,一般会将时间显示成“刚刚”,“5分钟前”,“3小时前”等,而不是直接将时间打印出来。比如微博,SNS类应用就最长用到这个功能。而一般存储在数据库中的时间...

php树型类实例

本文实例讲述了php树型类。分享给大家供大家参考。具体分析如下: 该实例原理简单,学过数据结构的一看就明白是什么道理了,不过今天在使用时数据中出现了子节点id(71)小于父节点id(10...

两款万能的php分页类

本文为大家分享个超级好用、万能的php分页类,具体的实现代码如下 第一款php分页类 <?php /* * To change this template, choo...

Ubuntu 16.04下安装PHP 7过程详解

前言 最近由于换了硬盘重装了(升级)系统到Ubuntu16.04之后,开发环境也要重新安装,其实16.04源里面默认的PHP版本就是7.x,但是有个问题就是没有OCI扩展,有项目需要使用...

php中通过DirectoryIterator删除整个目录的方法

本文实例讲述了php中通过DirectoryIterator删除整个目录的方法。分享给大家供大家参考。具体实现方法如下: <?php function cleanup_...