The usage method is as follows, we can see the use of miniXML, compared with the ActiveLink-PHP-XML-Package-0.4.0, more in line with the use of habits, but also more simple.
$ 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 ();
There are two ways to add a child element. The first is to directly add the node createChild, the second is to first create element in xmlDoc, and then the node is in appendChild.
The output is as follows:
<? 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 and tomorrow </song>
</Achild>
Obviously, the usage of mini-XML is very simple, especially for XML files that simply store data. For details, see the example provided by mini-XML. this is not detailed here.
========================================================== ======================================
Analysis
The structure of the minixml file is:
Minixml. inc. php
------ Classes
----------- Doc. inc. php element. inc. php node. inc. php treecomp. inc. php
Detailed API description, on the official website has introduced: http://minixml.psychogenic.com/api.html.