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.

相关文章

thinkphp中的多表关联查询的实例详解

thinkphp中的多表关联查询的实例详解  在进行后端管理系统的编程的时候一般会使用框架来进行页面的快速搭建,我最近使用比较多的就是thinkphp框架,thinkphp框架...

ueditor 1.2.6 使用方法说明

ueditor 1.2.6 使用方法说明

本文以php版本为例:文件下载:http://ueditor.baidu.com/website/download.html还可以自己先定义内容,然后下载,这样可以帮助我们精简不少东西。...

PHP记录搜索引擎蜘蛛访问网站足迹的方法

本文实例讲述了PHP记录搜索引擎蜘蛛访问网站足迹的方法。分享给大家供大家参考。具体分析如下: 搜索引擎的蜘蛛访问网站是通过远程抓取页面来进行的,我们不能使用JS代码来取得蜘蛛的Agent...

PHP根据两点间的经纬度计算距离

这是一个不错的示例,直接贴代码,首先要知道纬度值、经度值 /** * @desc 根据两点间的经纬度计算距离 * @param float $lat 纬度值 * @param...

PHP正则匹配日期和时间(时间戳转换)的实例代码

先来一个比较简单实用的代码 日期YYYY-MM-DD $str = ''; $isMatched = preg_match('/^\d{4}(\-|\/|.)\d{1,2}\1\d{...