php minixml详解

前端之家收集整理的这篇文章主要介绍了php minixml详解前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

使用方法如下,可以看到miniXML的使用,与ActiveLink-PHP-XML-Package-0.4.0相比,更加符合使用习惯,也更加的简单. $xmlDoc=newMiniXMLDoc();
$xmlRoot=&$xmlDoc->getRoot();
$childElement=&$xmlRoot->createChild(\'achild\');
$childElement->attribute(\'name\',\'annie\');
$childElement->text(\'Thiselementhasattributesandchildren,suchasthis\');
$image=&$childElement->createChild(\'image\');
$image->attribute(\'location\',\'http://psychogenic.com/image.png\');
$childElement->text(\'imageandlittle\');
$orphan=&$xmlDoc->createElement(\'song\');
$orphan->text(\'tomorrow,tomorrow\');
$childElement->appendChild($orphan);
print$xmlDoc->toString(); 添加一个子元素,有两种方式,第一种是直接该结点createChild,第二种是先xmlDoc先createElement,然后,该结点在appendChild. 最后打印出来的结果是:
<?xmlversion="1.0"?>
<achildname="annie"eyes="#0000FF"hair="#FF0000">
Thiselementhasattributesandchildren,suchasthis
<imagelocation="http://psychogenic.com/image.png"/&gt;
imageandlittle
tomorrow,tomorrow

可以很明显的看得出,miniXML的使用方法是非常简单的,尤其是对于简单的保存数据的XML文件,更是如此,详细可以看miniXML提供的例子.此处不详说. ========================================================================= 解析 minixml文件结构是:
minixml.inc.PHP
------classes
-----------doc.inc.PHPelement.inc.PHPnode.inc.PHPtreecomp.inc.PHP 详细的API解释说明,在官方网站上有介绍:http://minixml.psychogenic.com/api.html.

原文链接:https://www.f2er.com/php/29568.html

猜你在找的PHP相关文章