The usage method is as follows. You can see that the use of miniXML is more consistent with usage habits and simpler than 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();
There are two ways to add a child element, the first is to createChild directly on the node, the second is to createElement first with xmlDoc, and then, the node is in appendChild.
The final printed result is:
This element has attributes and children, such as this
image and little
< song> tomorrow, tomorrow
It is obvious that the use of miniXML is very simple, especially for simple saving This is especially true for data XML files. For details, you can see the examples provided by miniXML. No details are given here.
======================== ================================================== =
Analysis
minixml file structure is:
minixml.inc.php
-------classes
---------- -doc.inc.php element.inc.php node.inc.php treecomp.inc.php
Detailed API explanation is introduced on the official website: http://minixml.psychogenic.com/ api.html.