In real life, many things are related to each other to a certain extent. For example, China has many provinces, and under each province there are many cities. The relationships among these provinces and cities can be described in a tree structure, as shown in Figure 1.

Fig. 1 Urban relationship map

Figure 1 intuitively describes the hierarchical relationship between China and the provinces and cities under its jurisdiction. However, it is very difficult for the program to parse the content of the picture. At this time, it is the best choice to use XML file to save the data with tree structure.

XML is the abbreviation of Extensible Markup Language, which is a Markup Language similar to HTML, called Extensible Markup Language. By extensible, I mean that users can customize markup according to XML rules.

Next, an XML document is used to describe the relationship shown in Figure 1, as shown in Example 1.

Case 1 city. XML

< China > < > in hebei zhangjiakou city / < > of < city > < city > shijiazhuang city < / > < / hebei > < > in shanxi taiyuan city > < < / city > < city > datong city < / > < / shanxi > > < / China

In Example 1, < Chinese >, < Hebei >, and < City > are user-created tags that can be called elements. These elements must appear in pairs, that is, the start tag and the end tag. For example, in the < Chinese > element, the start tag is < Chinese > and the end tag is </ Chinese >. < Chinese > is treated as the root element of the entire XML document, and below it there are two sub-elements, < Hebei > and < Shanxi >, which contain two < city > elements, respectively. In XML documents, complex information with a tree hierarchy can be accurately described through the nested relationships of elements. Therefore, more and more applications are adopting XML format to store relevant configuration information for easy reading and modification.