XML development basics-XML tree structure

Source: Internet
Author: User
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!

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.