php minixml詳解_php技巧

來源:互聯網
上載者:User
使用方法如下,可以看到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="yun_qi_img/leech.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.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.