XML basic introduction and XML tag element _php techniques for PHP operation XML Introduction

Source: Internet
Author: User

This article illustrates the XML basic introduction and XML tag elements of the Introduction to PHP operations XML. Share to everyone for your reference. The specific analysis is as follows:

Explained in XML instance:

Copy Code code as follows:
<?xml version= "1.0" encoding= "Utf-8" standalone= "no"?>
<class>
<student>
<name> Little Joe </name>
<sex> Women </sex>
<age>23</age>
</student>
<student>
<name> Zhou Yu </name>
<sex> male </sex>
<age>27</age>
</student>
</class>

First, the XML declaration:

<?xml version= "1.0" encoding= "Utf-8" standalone= "no"?>
(1), the XML declaration to be placed in the first line of the document;
(2), Encoding: Document character encoding, such as Utf-8, gb2312, etc.
(3), standalone: The value is yes or no, optional, indicating whether the document definition is independent, that is, with other documents are associated. The default is No.

Two, the root element

The package at the outermost <class></class> is the root element, and each XML document must have a single root element.

Three, XML elements/tags/nodes

<student></student>, <name></name>, <sex></sex>, <age></age> are elements of XML, which are also called tags or nodes. Of course, the root element is also an element.
If there is no content in the label, such as no entity content between <name></name>, it can be abbreviated to <name/>. Even if it is written as <name></name>, it is also displayed <name when the browser is open/>

Four, the label in the space and line wrapping

The spaces and lines that appear in the label, and the XML document treats the space and the newline as the original content. Therefore, special attention should be paid to programming.

Naming conventions FOR XML tags

(1) Case sensitive;
(2) cannot begin with a number or "_";
(3) Can not start with XML, XML, XML and other special characters;
(4) cannot contain spaces;
(5) cannot contain a colon.

I hope this article will help you with your PHP operating XML program.

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.