Php mini-XML

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.