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开发的9条建议

本文只是个人从实际开发经验中总结的一些东西,并不是什么名言警句,写出来有两个目的:一是时刻提醒自己要按照这些知识点来写自己代码,二是为了分享,说不定对你有用呢?万一,是吧。。。 1.首要...

一个基于PDO的数据库操作类

百度之后决定使用PDO,至于为什么选择PDO,这里就不再多说,大家自己去百度下就能明白。 既然要换,那最基本就需要有个常用的数据库操作类,也就是所谓的增删改查等,昨晚捣腾了一晚,大致弄出...

php相当简单的分页类

class Helper_Page{ /** 总信息数 */ var $infoCount; /** 总页数 */ var $pageCount; /** 每页显示条数 */ var $...

PHP实现基数排序的方法详解

PHP实现基数排序的方法详解

本文实例讲述了PHP实现基数排序的方法。分享给大家供大家参考,具体如下: 基数排序是根据关键字中各位的值,通过对排序的N个元素进行若干趟“分配”与“收集”来实现排序的。 不妨通过一个具体...

PHP实现定时执行任务的方法

本文实例讲述了PHP实现定时执行任务的方法,代码简单实用。分享给大家供大家参考。 具体实现方法如下: ignore_user_abort(true); //客户端断开时忽略脚本中止(...