XML documents form a tree structure that begins with "root" and expands to "branches ". An XML document instance XML uses a simple self-descriptive syntax: the XML document forms a tree structure that begins with "root" and expands to "branches ".
An XML document instance
XML uses a simple self-descriptive syntax:
George
John
Reminder
Don't forget the meeting this weekend!
The first line is the XML declaration. It defines the XML version (1.0) and the encoding used (ISO-8859-1 = Latin-1/Western European character set ).
The following line describes the root element of the document (for example, "This document is a note "):
The following four lines describe the four child elements (to, from, heading, and body) of the root ):
George
John
Reminder
Don't forget the meeting this weekend!
The last line defines the end of the root element:
In this example, we can imagine that the XML document contains a signature John gave George.
XML has excellent self-description. do you agree?
XML documents form a tree structure
The XML document must contain the root element. This element is the parent element of all other elements.
The elements in the XML document form a document tree. The tree starts from the root and expands to the bottom of the tree.
All elements can have child elements:
.....
Terminologies such as parent, child, and compatriot are used to describe the relationship between elements. The parent element has child elements. Child elements at the same level become siblings ).
All elements can have text content and attributes (similar to HTML ).
Instance
Represents a book in the following XML:
Everyday Italian Giada De Laurentiis
2005
30.00
Harry Potter J K. Rowling
2005
29.99
LearningXML Erik T. Ray
2003
39.95
In this example, the root element is . All All elements are included in .
The element has four child elements: , <Author>, , .
The above is the detailed content of the XML tree structure, which is the basis for XML development. For more information, see other related articles in the first PHP community!