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

PHP
PHP与MySQL开发中页面出现乱码的一种解决方法
在PHP里得到前天和昨天的日期的代码
PHP4和PHP5性能测试和对比 测试代码与环境
wordpress之wp-settings.php
PHP下几种删除目录的方法总结
discuz 首页四格:最新话题+最新回复+热门话题+精华文章插件
海河写的 Discuz论坛帖子调用js的php代码
利用static实现表格的颜色隔行显示的代码
从一个不错的留言本弄的mysql数据库操作类
从MySQL数据库表中取出随机数据的代码
56.com视频采集接口程序(PHP)
php下实现伪 url 的超简单方法[转]
一些常用的php简单命令代码集锦
用windows下编译过的eAccelerator for PHP 5.1.6实现php加速的使用方法
实现php加速的eAccelerator dll支持文件打包下载
使用 eAccelerator加速PHP代码的方法
pw的一个放后门的方法分析
php在线生成ico文件的代码
一个图形显示IP的PHP程序代码
[PHP]实用函数2

PHP 中的 php minixml详解


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 116 ::
收藏到网摘: 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.